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

start_import_worker.rb « stage « jira_import « gitlab « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f6ad66e2781d20c81a345fa663b2b7fcafc5fa0 (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
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

module Gitlab
  module JiraImport
    module Stage
      class StartImportWorker # rubocop:disable Scalability/IdempotentWorker
        include ApplicationWorker

        data_consistency :always

        sidekiq_options retry: 3
        include ProjectStartImport
        include ProjectImportOptions
        include Gitlab::JiraImport::QueueOptions

        attr_reader :project

        def perform(project_id)
          @project = Project.find_by_id(project_id)

          return unless start_import

          Gitlab::Import::SetAsyncJid.set_jid(project.latest_jira_import)

          Gitlab::JiraImport::Stage::ImportLabelsWorker.perform_async(project.id)
        end

        private

        def start_import
          return false unless project
          return true if start(project.latest_jira_import)

          Gitlab::Import::Logger.info(
            {
              project_id: project.id,
              project_path: project.full_path,
              state: project&.jira_import_status,
              message: 'inconsistent state while importing'
            }
          )
          false
        end
      end
    end
  end
end