summaryrefslogtreecommitdiff
path: root/app/workers/bulk_imports/entity_worker.rb
blob: 5b41ccbdea1cac6dbcd7fc30d6cfef13d786df70 (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 BulkImports
  class EntityWorker # rubocop:disable Scalability/IdempotentWorker
    include ApplicationWorker

    feature_category :importers

    sidekiq_options retry: false, dead: false

    worker_has_external_dependencies!

    def perform(entity_id)
      entity = BulkImports::Entity.with_status(:started).find_by_id(entity_id)

      if entity
        entity.update!(jid: jid)

        BulkImports::Importers::GroupImporter.new(entity).execute
      end

    rescue => e
      extra = {
        bulk_import_id: entity&.bulk_import&.id,
        entity_id: entity&.id
      }

      Gitlab::ErrorTracking.track_exception(e, extra)

      entity&.fail_op
    end
  end
end