Commit 94b8f283 authored by Matija Čupić's avatar Matija Čupić

Expose upstream/downstream pipelines

parent 7f944ed8
...@@ -10,20 +10,18 @@ class DashboardOperationsProjectEntity < Grape::Entity ...@@ -10,20 +10,18 @@ class DashboardOperationsProjectEntity < Grape::Entity
end end
expose :last_pipeline, if: -> (*) { last_pipeline } do |dashboard_project, options| expose :last_pipeline, if: -> (*) { last_pipeline } do |dashboard_project, options|
new_request = EntityRequest.new(
current_user: request.current_user,
project: dashboard_project.project
)
PipelineEntity.represent(last_pipeline, options.merge(request: new_request)) PipelineEntity.represent(last_pipeline, options.merge(request: new_request))
end end
expose :last_deployment, if: -> (*) { last_deployment? } do |dashboard_project, options| expose :upstream_pipeline, if: -> (*) { upstream_pipeline } do |dashboard_project, options|
new_request = EntityRequest.new( PipelineEntity.represent(upstream_pipeline, options.merge(request: new_request))
current_user: request.current_user, end
project: dashboard_project.project
) expose :downstream_pipelines, if: -> (*) { downstream_pipelines } do |dashboard_project, options|
PipelineEntity.represent(downstream_pipelines, options.merge(request: new_request))
end
expose :last_deployment, if: -> (*) { last_deployment? } do |dashboard_project, options|
DeploymentEntity.represent(dashboard_project.last_deployment, DeploymentEntity.represent(dashboard_project.last_deployment,
options.merge(request: new_request)) options.merge(request: new_request))
end end
...@@ -41,8 +39,23 @@ class DashboardOperationsProjectEntity < Grape::Entity ...@@ -41,8 +39,23 @@ class DashboardOperationsProjectEntity < Grape::Entity
alias_method :dashboard_project, :object alias_method :dashboard_project, :object
def new_request
EntityRequest.new(
current_user: request.current_user,
project: dashboard_project.project
)
end
def upstream_pipeline
last_pipeline&.source_pipeline&.source_pipeline
end
def downstream_pipelines
last_pipeline&.sourced_pipelines&.map(&:source_pipeline)
end
def last_pipeline def last_pipeline
dashboard_project.project.commit.last_pipeline dashboard_project.project.commit&.last_pipeline
end end
def last_deployment? def last_deployment?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment