Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-08-28 10:51:26 +0300
committerShinya Maeda <shinya@gitlab.com>2019-09-03 09:30:53 +0300
commit8c21610c79d2737c9cd728964f499d793e6a1279 (patch)
tree82af1d1bed4f1a522658b3dfb7c0bc8a766e88cd /app/serializers/pipeline_entity.rb
parent991143eb1f1bb5cda1f709ad44fdc021aa12b75d (diff)
Add pipeline.type key to PipelineEntity
This commit adds pipeline.type key to PipelineEntity. This key will be used in MR widget in the next iteration.
Diffstat (limited to 'app/serializers/pipeline_entity.rb')
-rw-r--r--app/serializers/pipeline_entity.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 9ef93b2387f..94e8b174f0f 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -2,6 +2,9 @@
class PipelineEntity < Grape::Entity
include RequestAwareEntity
+ include Gitlab::Utils::StrongMemoize
+
+ delegate :name, :failure_reason, to: :presented_pipeline
expose :id
expose :user, using: UserEntity
@@ -36,6 +39,7 @@ class PipelineEntity < Grape::Entity
expose :ordered_stages, as: :stages, using: StageEntity
expose :duration
expose :finished_at
+ expose :name
end
expose :merge_request, if: -> (*) { has_presentable_merge_request? }, with: MergeRequestForPipelineEntity do |pipeline|
@@ -59,13 +63,11 @@ class PipelineEntity < Grape::Entity
end
expose :commit, using: CommitEntity
+ expose :merge_request_event_type, if: -> (pipeline, _) { pipeline.merge_request_event? }
expose :source_sha, if: -> (pipeline, _) { pipeline.merge_request_pipeline? }
expose :target_sha, if: -> (pipeline, _) { pipeline.merge_request_pipeline? }
expose :yaml_errors, if: -> (pipeline, _) { pipeline.has_yaml_errors? }
-
- expose :failure_reason, if: -> (pipeline, _) { pipeline.failure_reason? } do |pipeline|
- pipeline.present.failure_reason
- end
+ expose :failure_reason, if: -> (pipeline, _) { pipeline.failure_reason? }
expose :retry_path, if: -> (*) { can_retry? } do |pipeline|
retry_project_pipeline_path(pipeline.project, pipeline)
@@ -97,4 +99,10 @@ class PipelineEntity < Grape::Entity
def detailed_status
pipeline.detailed_status(request.current_user)
end
+
+ def presented_pipeline
+ strong_memoize(:presented_pipeline) do
+ pipeline.present
+ end
+ end
end