fix(sentry#3144617191): render filesize to follow archive nicely

This commit is contained in:
Martin 2022-04-21 17:29:42 +02:00
parent 4a9250f377
commit 220db1f30e
2 changed files with 6 additions and 12 deletions

View file

@ -12,7 +12,7 @@ class ArchiveDashboard < Administrate::BaseDashboard
created_at: Field::DateTime,
updated_at: Field::DateTime,
status: Field::String,
file: Field::HasOne
file: AttachmentField
}.freeze
# COLLECTION_ATTRIBUTES
@ -24,7 +24,8 @@ class ArchiveDashboard < Administrate::BaseDashboard
:id,
:created_at,
:updated_at,
:status
:status,
:file
].freeze
# SHOW_PAGE_ATTRIBUTES
@ -33,14 +34,6 @@ class ArchiveDashboard < Administrate::BaseDashboard
:id,
:created_at,
:updated_at,
:status,
:file
:status
].freeze
# Overwrite this method to customize how users are displayed
# across all pages of the admin dashboard.
#
def display_resource(archive)
"Archive : #{archive&.file.&byte_size}"
end
end

View file

@ -1,8 +1,9 @@
require "administrate/field/base"
class AttachmentField < Administrate::Field::Base
include ActionView::Helpers::NumberHelper
def to_s
data.filename.to_s
"#{data.filename} (#{number_to_human_size(data.byte_size)})"
end
def blob_path