summaryrefslogtreecommitdiff
path: root/lib/bulk_imports/groups/pipelines/entity_finisher.rb
blob: 1d237bc0f7ffe9f915c4dbc0eb139bb2da09a251 (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
# frozen_string_literal: true

module BulkImports
  module Groups
    module Pipelines
      class EntityFinisher
        def initialize(context)
          @context = context
        end

        def run
          return if context.entity.finished?

          context.entity.finish!

          logger.info(
            bulk_import_id: context.bulk_import.id,
            bulk_import_entity_id: context.entity.id,
            bulk_import_entity_type: context.entity.source_type,
            pipeline_class: self.class.name,
            message: 'Entity finished'
          )
        end

        private

        attr_reader :context

        def logger
          @logger ||= Gitlab::Import::Logger.build
        end
      end
    end
  end
end