From 3c6cad91a1a9d8732e8cb998f83d32dc19373b7b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 14 Oct 2022 18:08:40 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/project_statistics.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'app') 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, []) -- cgit v1.2.3