Class: BulkImports::Common::Pipelines::BadgesPipeline
- Inherits:
-
Object
- Object
- BulkImports::Common::Pipelines::BadgesPipeline
- Includes:
- Pipeline, HexdigestCacheStrategy
- Defined in:
- lib/bulk_imports/common/pipelines/badges_pipeline.rb
Constant Summary
Constants included from Pipeline
Pipeline::CACHE_KEY_EXPIRATION, Pipeline::EMPTY_EXPORT_STATUS_TIMEOUT, Pipeline::ExpiredError, Pipeline::FailedError, Pipeline::NDJSON_EXPORT_TIMEOUT, Pipeline::NotAllowedError
Constants included from Pipeline::Runner
Pipeline::Runner::MarkedAsFailedError
Instance Method Summary collapse
Methods included from Pipeline
#current_user, #import_export_config, #initialize, #portable, #tracker
Methods included from Pipeline::Runner
Instance Method Details
#load(context, data) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/bulk_imports/common/pipelines/badges_pipeline.rb', line 27 def load(context, data) return if data.blank? if context.entity.project? context.portable.project_badges.create!(data) else context.portable.badges.create!(data) end end |
#transform(context, data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bulk_imports/common/pipelines/badges_pipeline.rb', line 15 def transform(context, data) return if data.blank? # Project badges API returns badges of both group and project kind. To avoid creation of duplicates for the group we skip group badges when it's a project. return if context.entity.project? && group_badge?(data) { name: data['name'], link_url: data['link_url'], image_url: data['image_url'] } end |