summaryrefslogtreecommitdiff
path: root/app/serializers/project_import_entity.rb
blob: 58360321f7c754b7f66d4d2e605c473dfccb09c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class ProjectImportEntity < ProjectEntity
  include ImportHelper

  expose :import_source, documentation: { type: 'string', example: 'source/source-repo' }
  expose :import_status, documentation: {
    type: 'string', example: 'scheduled', values: %w[scheduled started finished failed canceled]
  }
  expose :human_import_status_name, documentation: { type: 'string', example: 'canceled' }

  expose :provider_link, documentation: { type: 'string', example: '/source/source-repo' } do |project, options|
    provider_project_link_url(options[:provider_url], project[:import_source])
  end

  expose :import_error, if: ->(project) { project.import_state&.failed? } do |project|
    project.import_failures.last&.exception_message
  end
end