import_worker.rb 744 Bytes
Newer Older
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
# frozen_string_literal: true

module Gitlab
  module JiraImport
    module ImportWorker
      extend ActiveSupport::Concern

      included do
        include ApplicationWorker
        include Gitlab::JiraImport::QueueOptions
      end

      def perform(project_id)
        project = Project.find_by(id: project_id) # rubocop: disable CodeReuse/ActiveRecord

        return unless can_import?(project)

        import(project)
      end

      private

      def import(project)
        raise NotImplementedError
      end

      def can_import?(project)
        return false unless project
29
        return false unless project.jira_issues_import_feature_flag_enabled?
30

31
        project.latest_jira_import&.started?
32
33
34
35
      end
    end
  end
end