Move conditional statement to PipelineSerializer#represent_status
This commit is contained in:
parent
a375d80eb0
commit
1d75989551
2 changed files with 1 additions and 1 deletions
|
@ -474,7 +474,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def pipeline_status
|
def pipeline_status
|
||||||
render json: {} and return unless @merge_request.head_pipeline.present?
|
|
||||||
render json: PipelineSerializer
|
render json: PipelineSerializer
|
||||||
.new(project: @project, user: @current_user)
|
.new(project: @project, user: @current_user)
|
||||||
.represent_status(@merge_request.head_pipeline)
|
.represent_status(@merge_request.head_pipeline)
|
||||||
|
|
|
@ -24,6 +24,7 @@ class PipelineSerializer < BaseSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def represent_status(resource)
|
def represent_status(resource)
|
||||||
|
return {} unless resource.present?
|
||||||
data = represent(resource, { only: [{ details: [:status] }] })
|
data = represent(resource, { only: [{ details: [:status] }] })
|
||||||
data.dig(:details, :status) || {}
|
data.dig(:details, :status) || {}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue