2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-22 16:58:10 +00:00
|
|
|
module StorageHelper
|
|
|
|
def storage_counter(size_in_bytes)
|
2019-05-16 10:30:42 +00:00
|
|
|
return s_('StorageSize|Unknown') unless size_in_bytes
|
|
|
|
|
2016-11-22 16:58:10 +00:00
|
|
|
precision = size_in_bytes < 1.megabyte ? 0 : 1
|
|
|
|
|
|
|
|
number_to_human_size(size_in_bytes, delimiter: ',', precision: precision, significant: false)
|
|
|
|
end
|
2019-05-02 16:04:15 +00:00
|
|
|
|
|
|
|
def storage_counters_details(statistics)
|
|
|
|
counters = {
|
|
|
|
counter_repositories: storage_counter(statistics.repository_size),
|
2019-02-13 22:38:11 +00:00
|
|
|
counter_wikis: storage_counter(statistics.wiki_size),
|
2019-05-02 16:04:15 +00:00
|
|
|
counter_build_artifacts: storage_counter(statistics.build_artifacts_size),
|
2020-06-30 12:08:57 +00:00
|
|
|
counter_lfs_objects: storage_counter(statistics.lfs_objects_size),
|
|
|
|
counter_snippets: storage_counter(statistics.snippets_size)
|
2019-05-02 16:04:15 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 12:08:57 +00:00
|
|
|
_("Repository: %{counter_repositories} / Wikis: %{counter_wikis} / Build Artifacts: %{counter_build_artifacts} / LFS: %{counter_lfs_objects} / Snippets: %{counter_snippets}") % counters
|
2019-05-02 16:04:15 +00:00
|
|
|
end
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|