diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-21 00:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-21 00:08:53 +0300 |
commit | 22fe7d7df6b91040d6cecbfd78f24c563afed463 (patch) | |
tree | 8c2baf2ed9f93e13680e9288ad30adb4fa1ae04a /app/models/namespace | |
parent | e32f083f49a50ee2f7c217eb0d51d759958145f3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/namespace')
-rw-r--r-- | app/models/namespace/root_storage_statistics.rb | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/app/models/namespace/root_storage_statistics.rb b/app/models/namespace/root_storage_statistics.rb index 96715863892..6a0aa52393d 100644 --- a/app/models/namespace/root_storage_statistics.rb +++ b/app/models/namespace/root_storage_statistics.rb @@ -44,15 +44,28 @@ class Namespace::RootStorageStatistics < ApplicationRecord def merged_attributes attributes_from_project_statistics.merge!( attributes_from_personal_snippets, - attributes_from_namespace_statistics + attributes_from_namespace_statistics, + attributes_for_container_registry_size ) { |key, v1, v2| v1 + v2 } end + def attributes_for_container_registry_size + return {} unless Feature.enabled?(:container_registry_namespace_statistics, namespace) + + container_registry_size = namespace.container_repositories_size || 0 + + { + storage_size: container_registry_size, + container_registry_size: container_registry_size + }.with_indifferent_access + end + def attributes_from_project_statistics from_project_statistics - .take - .attributes - .slice(*STATISTICS_ATTRIBUTES) + .take + .attributes + .slice(*STATISTICS_ATTRIBUTES) + .with_indifferent_access end def from_project_statistics @@ -74,7 +87,10 @@ class Namespace::RootStorageStatistics < ApplicationRecord def attributes_from_personal_snippets return {} unless namespace.user_namespace? - from_personal_snippets.take.slice(SNIPPETS_SIZE_STAT_NAME) + from_personal_snippets + .take + .slice(SNIPPETS_SIZE_STAT_NAME) + .with_indifferent_access end def from_personal_snippets @@ -102,7 +118,12 @@ class Namespace::RootStorageStatistics < ApplicationRecord # guard clause. return {} unless namespace.group_namespace? - from_namespace_statistics.take.slice(*self.class.namespace_statistics_attributes) + from_namespace_statistics + .take + .slice( + *self.class.namespace_statistics_attributes + ) + .with_indifferent_access end end |