File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ namespace :asdb do
2020 desc 'ActiveStorageDB: list attachments ordered by blob id desc'
2121 task list : [ :environment ] do |_t , _args |
2222 query = ::ActiveStorage ::Blob . order ( id : :desc ) . limit ( 100 )
23- digits = Math . log ( query . maximum ( :id ) , 10 ) . to_i + 1
23+ digits = query . ids . inject ( 0 ) { | ret , id | size = id . to_s . size ; [ size , ret ] . max }
2424
2525 ::ActiveStorage ::Tasks . print_blob_header ( digits : digits )
2626 query . each do |blob |
@@ -52,7 +52,7 @@ namespace :asdb do
5252
5353 blobs = ::ActiveStorage ::Blob . where ( 'filename LIKE ?' , "%#{ filename } %" ) . order ( id : :desc )
5454 if blobs . any?
55- digits = Math . log ( blobs . first . id , 10 ) . to_i + 1
55+ digits = blobs . ids . inject ( 0 ) { | ret , id | size = id . to_s . size ; [ size , ret ] . max }
5656 ::ActiveStorage ::Tasks . print_blob_header ( digits : digits )
5757 blobs . each do |blob |
5858 ::ActiveStorage ::Tasks . print_blob ( blob , digits : digits )
You can’t perform that action at this time.
0 commit comments