diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-14 21:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-14 21:08:40 +0300 |
commit | 3c6cad91a1a9d8732e8cb998f83d32dc19373b7b (patch) | |
tree | 1fca87ffaa7d72b66529a00b1126e796b4e4cb32 /app | |
parent | 1ab98e892c57b409d5ac3d643fdebc93de5a08dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_statistics.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index e13f8d28c92..f108e43015e 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -37,7 +37,6 @@ class ProjectStatistics < ApplicationRecord :pipeline_artifacts_size, :uploads_size ].freeze - STORAGE_SIZE_SUM = STORAGE_SIZE_COMPONENTS.map { |component| "COALESCE (#{component}, 0)" }.join(' + ').freeze scope :for_project_ids, ->(project_ids) { where(project_id: project_ids) } @@ -109,12 +108,12 @@ class ProjectStatistics < ApplicationRecord end def update_storage_size - self.storage_size = STORAGE_SIZE_COMPONENTS.sum { |component| method(component).call } + self.storage_size = storage_size_components.sum { |component| method(component).call } end def refresh_storage_size! detect_race_on_record(log_fields: { caller: __method__, attributes: :storage_size }) do - update!(storage_size: STORAGE_SIZE_SUM) + update!(storage_size: storage_size_sum) end end @@ -151,6 +150,14 @@ class ProjectStatistics < ApplicationRecord private + def storage_size_components + STORAGE_SIZE_COMPONENTS + end + + def storage_size_sum + storage_size_components.map { |component| "COALESCE (#{component}, 0)" }.join(' + ').freeze + end + def increment_columns!(key, amount) increments = { key => amount } additional = INCREMENTABLE_COLUMNS.fetch(key, []) |