5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/active_storage_dashboard/dashboard_controller.rb', line 5
def index
@blobs_count = ActiveStorage::Blob.count
@attachments_count = ActiveStorage::Attachment.count
@variant_records_count = defined?(ActiveStorage::VariantRecord) ? ActiveStorage::VariantRecord.count : 0
@total_storage = ActiveStorage::Blob.sum(:byte_size)
@content_types = ActiveStorage::Blob.group(:content_type).count.sort_by { |_, count| -count }.first(5)
@recent_blobs = ActiveStorage::Blob.order(created_at: :desc).limit(5)
@purgable_blobs = ActiveStorage::Blob.left_outer_joins(:attachments)
.where(active_storage_attachments: { id: nil })
@largest_blob = ActiveStorage::Blob.order(byte_size: :desc).first
@blobs_by_month = {}
begin
load_timeline_data
rescue => e
Rails.logger.error "Error in timeline chart preparation: #{e.message}"
generate_sample_timeline_data
end
end
|