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

badges_pipeline.rb « pipelines « groups « bulk_imports « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8569ff3f77a59fa2341cde2eecfbca4d94e28a9b (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
# frozen_string_literal: true

module BulkImports
  module Groups
    module Pipelines
      class BadgesPipeline
        include Pipeline

        extractor BulkImports::Common::Extractors::RestExtractor,
          query: BulkImports::Groups::Rest::GetBadgesQuery

        transformer Common::Transformers::ProhibitedAttributesTransformer

        def transform(_, data)
          return if data.blank?

          {
            name: data['name'],
            link_url: data['link_url'],
            image_url: data['image_url']
          }
        end

        def load(context, data)
          return if data.blank?

          context.group.badges.create!(data)
        end
      end
    end
  end
end