Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reschedule_stuck_issue_rebalances_worker.rb « issues « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 77cedae558b1ab5b884d43a5e50ec53468ed43aa (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
34
35
36
# frozen_string_literal: true

module Issues
  class RescheduleStuckIssueRebalancesWorker
    include ApplicationWorker
    include CronjobQueue

    data_consistency :sticky

    idempotent!
    urgency :low
    feature_category :team_planning
    deduplicate :until_executed, including_scheduled: true

    def perform
      namespace_ids, project_ids = ::Gitlab::Issues::Rebalancing::State.fetch_rebalancing_groups_and_projects

      return if namespace_ids.blank? && project_ids.blank?

      namespaces = Namespace.id_in(namespace_ids)
      projects = Project.id_in(project_ids)

      Issues::RebalancingWorker.bulk_perform_async_with_contexts(
        namespaces,
        arguments_proc: -> (namespace) { [nil, nil, namespace.id] },
        context_proc: -> (namespace) { { namespace: namespace } }
      )

      Issues::RebalancingWorker.bulk_perform_async_with_contexts(
        projects,
        arguments_proc: -> (project) { [nil, project.id, nil] },
        context_proc: -> (project) { { project: project } }
      )
    end
  end
end