summaryrefslogtreecommitdiff
path: root/app/workers/projects/finalize_project_statistics_refresh_worker.rb
blob: d8b06f55c38a6a9c47bcfe2f2622fbbe68d718d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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