mirror of https://github.com/tootsuite/mastodon
Use `print_table` to wrap storage output CLI (#32230)
parent
1db91ab8d9
commit
52afa94f1c
|
@ -278,14 +278,10 @@ module Mastodon::CLI
|
||||||
|
|
||||||
desc 'usage', 'Calculate disk space consumed by Mastodon'
|
desc 'usage', 'Calculate disk space consumed by Mastodon'
|
||||||
def usage
|
def usage
|
||||||
say("Attachments:\t#{number_to_human_size(media_attachment_storage_size)} (#{number_to_human_size(local_media_attachment_storage_size)} local)")
|
print_table [
|
||||||
say("Custom emoji:\t#{number_to_human_size(CustomEmoji.sum(:image_file_size))} (#{number_to_human_size(CustomEmoji.local.sum(:image_file_size))} local)")
|
%w(Object Total Local),
|
||||||
say("Preview cards:\t#{number_to_human_size(PreviewCard.sum(:image_file_size))}")
|
*object_storage_summary,
|
||||||
say("Avatars:\t#{number_to_human_size(Account.sum(:avatar_file_size))} (#{number_to_human_size(Account.local.sum(:avatar_file_size))} local)")
|
]
|
||||||
say("Headers:\t#{number_to_human_size(Account.sum(:header_file_size))} (#{number_to_human_size(Account.local.sum(:header_file_size))} local)")
|
|
||||||
say("Backups:\t#{number_to_human_size(Backup.sum(:dump_file_size))}")
|
|
||||||
say("Imports:\t#{number_to_human_size(Import.sum(:data_file_size))}")
|
|
||||||
say("Settings:\t#{number_to_human_size(SiteUpload.sum(:file_file_size))}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'lookup URL', 'Lookup where media is displayed by passing a media URL'
|
desc 'lookup URL', 'Lookup where media is displayed by passing a media URL'
|
||||||
|
@ -318,20 +314,23 @@ module Mastodon::CLI
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def media_attachment_storage_size
|
def object_storage_summary
|
||||||
MediaAttachment.sum(file_and_thumbnail_size_sql)
|
[
|
||||||
|
[:attachments, MediaAttachment.sum(combined_media_sum), MediaAttachment.where(account: Account.local).sum(combined_media_sum)],
|
||||||
|
[:custom_emoji, CustomEmoji.sum(:image_file_size), CustomEmoji.local.sum(:image_file_size)],
|
||||||
|
[:avatars, Account.sum(:avatar_file_size), Account.local.sum(:avatar_file_size)],
|
||||||
|
[:headers, Account.sum(:header_file_size), Account.local.sum(:header_file_size)],
|
||||||
|
[:preview_cards, PreviewCard.sum(:image_file_size), nil],
|
||||||
|
[:backups, Backup.sum(:dump_file_size), nil],
|
||||||
|
[:imports, Import.sum(:data_file_size), nil],
|
||||||
|
[:settings, SiteUpload.sum(:file_file_size), nil],
|
||||||
|
].map { |label, total, local| [label.to_s.titleize, number_to_human_size(total), local.present? ? number_to_human_size(local) : nil] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_media_attachment_storage_size
|
def combined_media_sum
|
||||||
MediaAttachment.where(account: Account.local).sum(file_and_thumbnail_size_sql)
|
Arel.sql(<<~SQL.squish)
|
||||||
end
|
|
||||||
|
|
||||||
def file_and_thumbnail_size_sql
|
|
||||||
Arel.sql(
|
|
||||||
<<~SQL.squish
|
|
||||||
COALESCE(file_file_size, 0) + COALESCE(thumbnail_file_size, 0)
|
COALESCE(file_file_size, 0) + COALESCE(thumbnail_file_size, 0)
|
||||||
SQL
|
SQL
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
PRELOAD_MODEL_WHITELIST = %w(
|
PRELOAD_MODEL_WHITELIST = %w(
|
||||||
|
|
Loading…
Reference in New Issue