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

module BulkImports
  module Groups
    module Pipelines
      class LabelsPipeline
        include Pipeline

        extractor BulkImports::Common::Extractors::GraphqlExtractor,
          query: BulkImports::Groups::Graphql::GetLabelsQuery

        transformer Common::Transformers::ProhibitedAttributesTransformer

        def load(context, data)
          Labels::CreateService.new(data).execute(group: context.group)
        end

        def after_run(extracted_data)
          tracker.update(
            has_next_page: extracted_data.has_next_page?,
            next_page: extracted_data.next_page
          )

          if extracted_data.has_next_page?
            run
          end
        end
      end
    end
  end
end