2020-01-30 10:09:15 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class ProjectImportStatus < ProjectIdentity
|
|
|
|
expose :import_status
|
2020-04-08 14:09:16 -04:00
|
|
|
expose :correlation_id do |project, _options|
|
2020-04-14 05:09:34 -04:00
|
|
|
project.import_state&.correlation_id
|
2020-04-08 14:09:16 -04:00
|
|
|
end
|
2020-01-30 10:09:15 -05:00
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
expose :failed_relations, using: Entities::ProjectImportFailedRelation do |project, _options|
|
2020-04-23 14:09:46 -04:00
|
|
|
project.import_state&.relation_hard_failures(limit: 100) || []
|
2020-04-21 11:21:10 -04:00
|
|
|
end
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
# TODO: Use `expose_nil` once we upgrade the grape-entity gem
|
|
|
|
expose :import_error, if: lambda { |project, _ops| project.import_state&.last_error } do |project|
|
|
|
|
project.import_state.last_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|