debian-mirror-gitlab/app/helpers/storage_helper.rb

27 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module StorageHelper
def storage_counter(size_in_bytes)
2019-09-04 21:01:54 +05:30
return s_('StorageSize|Unknown') unless size_in_bytes
2017-08-17 22:00:37 +05:30
precision = size_in_bytes < 1.megabyte ? 0 : 1
number_to_human_size(size_in_bytes, delimiter: ',', precision: precision, significant: false)
end
2019-07-31 22:56:46 +05:30
def storage_counters_details(statistics)
counters = {
counter_repositories: storage_counter(statistics.repository_size),
2019-09-04 21:01:54 +05:30
counter_wikis: storage_counter(statistics.wiki_size),
2019-07-31 22:56:46 +05:30
counter_build_artifacts: storage_counter(statistics.build_artifacts_size),
2021-12-11 22:18:48 +05:30
counter_pipeline_artifacts: storage_counter(statistics.pipeline_artifacts_size),
2020-07-28 23:09:34 +05:30
counter_lfs_objects: storage_counter(statistics.lfs_objects_size),
2021-02-22 17:27:13 +05:30
counter_snippets: storage_counter(statistics.snippets_size),
counter_packages: storage_counter(statistics.packages_size),
counter_uploads: storage_counter(statistics.uploads_size)
2019-07-31 22:56:46 +05:30
}
2021-12-11 22:18:48 +05:30
_("Repository: %{counter_repositories} / Wikis: %{counter_wikis} / Build Artifacts: %{counter_build_artifacts} / Pipeline Artifacts: %{counter_pipeline_artifacts} / LFS: %{counter_lfs_objects} / Snippets: %{counter_snippets} / Packages: %{counter_packages} / Uploads: %{counter_uploads}") % counters
2019-07-31 22:56:46 +05:30
end
2017-08-17 22:00:37 +05:30
end