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
|
||||
|
||||
def pipeline_status
|
||||
render json: {} and return unless @merge_request.head_pipeline.present?
|
||||
render json: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
.represent_status(@merge_request.head_pipeline)
|
||||
|
|
|
@ -24,6 +24,7 @@ class PipelineSerializer < BaseSerializer
|
|||
end
|
||||
|
||||
def represent_status(resource)
|
||||
return {} unless resource.present?
|
||||
data = represent(resource, { only: [{ details: [:status] }] })
|
||||
data.dig(:details, :status) || {}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue