diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/services/ci/job_artifacts/destroy_associations_service.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/services/ci/job_artifacts/destroy_associations_service.rb')
-rw-r--r-- | app/services/ci/job_artifacts/destroy_associations_service.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/app/services/ci/job_artifacts/destroy_associations_service.rb b/app/services/ci/job_artifacts/destroy_associations_service.rb index 794d24eadf2..fd3e69a5913 100644 --- a/app/services/ci/job_artifacts/destroy_associations_service.rb +++ b/app/services/ci/job_artifacts/destroy_associations_service.rb @@ -2,27 +2,32 @@ module Ci module JobArtifacts + # This class is used by Ci::JobArtifact's FastDestroyAll implementation. + # Ci::JobArtifact.begin_fast_destroy instantiates this service and calls #destroy_records. + # This will set @statistics_updates instance variables. + # The same instance is passed to Ci::JobArtifact.finalize_fast_destroy, which then calls + # #update_statistics, using @statistics_updates set by #destroy_records. class DestroyAssociationsService BATCH_SIZE = 100 def initialize(job_artifacts_relation) @job_artifacts_relation = job_artifacts_relation - @statistics = {} + @statistics_updates = {} end def destroy_records @job_artifacts_relation.each_batch(of: BATCH_SIZE) do |relation| service = Ci::JobArtifacts::DestroyBatchService.new(relation, pick_up_at: Time.current) result = service.execute(update_stats: false) - updates = result[:statistics_updates] - - @statistics.merge!(updates) { |_key, oldval, newval| newval + oldval } + @statistics_updates.merge!(result[:statistics_updates]) do |_project, existing_updates, new_updates| + existing_updates.concat(new_updates) + end end end def update_statistics - @statistics.each do |project, delta| - project.increment_statistic_value(Ci::JobArtifact.project_statistics_name, delta) + @statistics_updates.each do |project, increments| + ProjectStatistics.bulk_increment_statistic(project, Ci::JobArtifact.project_statistics_name, increments) end end end |