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

unassign_issuables_worker.rb « members_destroyer « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 677a1be25ca186f69c20b8c59e9107d3badbc4e0 (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 MembersDestroyer
  class UnassignIssuablesWorker
    include ApplicationWorker

    data_consistency :always

    sidekiq_options retry: 3

    ENTITY_TYPES = %w[Group Project].freeze

    queue_namespace :unassign_issuables
    feature_category :user_management

    idempotent!

    def perform(user_id, entity_id, entity_type)
      unless ENTITY_TYPES.include?(entity_type)
        logger.error(
          message: "#{entity_type} is not a supported entity.",
          entity_type: entity_type,
          entity_id: entity_id,
          user_id: user_id
        )

        return
      end

      user = User.find(user_id)
      entity = entity_type.constantize.find(entity_id)

      ::Members::UnassignIssuablesService.new(user, entity).execute
    end
  end
end