@@ -57,7 +57,8 @@ def download_chunk(key, range)
5757
5858 def delete ( key )
5959 instrument :delete , key : key do
60- record = ::ActiveStorageDB ::File . find_by ( ref : key )
60+ comment = "DBService#delete"
61+ record = ::ActiveStorageDB ::File . annotate ( comment ) . find_by ( ref : key )
6162 record &.destroy
6263 # NOTE: Ignore files already deleted
6364 !record . nil?
@@ -66,15 +67,18 @@ def delete(key)
6667
6768 def delete_prefixed ( prefix )
6869 instrument :delete_prefixed , prefix : prefix do
69- ::ActiveStorageDB ::File . where ( 'ref LIKE ?' , "#{ ApplicationRecord . sanitize_sql_like ( prefix ) } %" ) . destroy_all
70+ comment = "DBService#delete_prefixed"
71+ sanitized_prefix = "#{ ApplicationRecord . sanitize_sql_like ( prefix ) } %"
72+ ::ActiveStorageDB ::File . annotate ( comment ) . where ( 'ref LIKE ?' , sanitized_prefix ) . destroy_all
7073 end
7174 end
7275
7376 def exist? ( key )
7477 instrument :exist , key : key do |payload |
75- answer = ::ActiveStorageDB ::File . where ( ref : key ) . exists?
76- payload [ :exist ] = answer
77- answer
78+ comment = "DBService#exist?"
79+ result = ::ActiveStorageDB ::File . annotate ( comment ) . where ( ref : key ) . exists?
80+ payload [ :exist ] = result
81+ result
7882 end
7983 end
8084
@@ -152,7 +156,8 @@ def retrieve_file(key)
152156 end
153157
154158 def object_for ( key , fields : nil )
155- as_file = fields ? ::ActiveStorageDB ::File . select ( *fields ) : ::ActiveStorageDB ::File
159+ comment = "DBService#object_for"
160+ as_file = fields ? ::ActiveStorageDB ::File . annotate ( comment ) . select ( *fields ) : ::ActiveStorageDB ::File
156161 as_file . find_by ( ref : key )
157162 end
158163
0 commit comments