summaryrefslogtreecommitdiff
path: root/app/workers/projects/finalize_project_statistics_refresh_worker.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/projects/finalize_project_statistics_refresh_worker.rb')
-rw-r--r--app/workers/projects/finalize_project_statistics_refresh_worker.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/workers/projects/finalize_project_statistics_refresh_worker.rb b/app/workers/projects/finalize_project_statistics_refresh_worker.rb
new file mode 100644
index 00000000000..d8b06f55c38
--- /dev/null
+++ b/app/workers/projects/finalize_project_statistics_refresh_worker.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Projects
+ class FinalizeProjectStatisticsRefreshWorker
+ include ApplicationWorker
+
+ data_consistency :always
+
+ loggable_arguments 0, 1
+
+ # The increments in `ProjectStatistics` are owned by several teams depending
+ # on the counter
+ feature_category :not_owned # rubocop:disable Gitlab/AvoidFeatureCategoryNotOwned
+
+ urgency :low
+ deduplicate :until_executing, including_scheduled: true
+
+ idempotent!
+
+ def perform(record_class, record_id)
+ if record_class.demodulize == 'BuildArtifactsSizeRefresh'
+ Gitlab::ApplicationContext.push(feature_category: :build_artifacts)
+ end
+
+ return unless self.class.const_defined?(record_class)
+
+ record = record_class.constantize.find_by_id(record_id)
+ return unless record
+
+ record.finalize!
+ end
+ end
+end