summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-05-06 10:08:42 +0200
committerFilipa Lacerda <filipa@gitlab.com>2019-05-24 10:04:04 +0100
commitb9c19f6b0f5c85956bf85935452c34fc6a21bcb0 (patch)
treea847bd3653357f6ebe5aa80ed416c1f0e7fe3e37 /app/serializers
parent819746dc6544820f41d66b87c2c68efc9b17e0f4 (diff)
downloadgitlab-ce-b9c19f6b0f5c85956bf85935452c34fc6a21bcb0.tar.gz
Do not serialize a pipeline again when showing a build
This change makes it possible to avoid additional serialization of entire pipeline when rendering a build details page. Instead we expose more information from the build entity itself what is much cheaper than serializing entire pipeline. Additionally we do not need to serialize `latest?` flag, which involves multiple Gitaly calls.
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/build_details_entity.rb9
-rw-r--r--app/serializers/pipeline_details_entity.rb5
-rw-r--r--app/serializers/pipeline_entity.rb2
3 files changed, 7 insertions, 9 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 2843132ef62..61420ce0219 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -8,11 +8,8 @@ class BuildDetailsEntity < JobEntity
expose :stuck?, as: :stuck
expose :user, using: UserEntity
expose :runner, using: RunnerEntity
-
- # expose :pipeline, using: PipelineEntity
- expose :pipeline_path do |build|
- project_pipeline_path(build.project, build.pipeline)
- end
+ expose :metadata, using: BuildMetadataEntity
+ expose :pipeline, using: PipelineEntity
expose :deployment_status, if: -> (*) { build.starts_environment? } do
expose :deployment_status, as: :status
@@ -20,8 +17,6 @@ class BuildDetailsEntity < JobEntity
expose :persisted_environment, as: :environment, with: EnvironmentEntity
end
- expose :metadata, using: BuildMetadataEntity
-
expose :artifact, if: -> (*) { can?(current_user, :read_build, build) } do
expose :download_path, if: -> (*) { build.artifacts? } do |build|
download_project_job_artifacts_path(project, build)
diff --git a/app/serializers/pipeline_details_entity.rb b/app/serializers/pipeline_details_entity.rb
index d78ad4af4dc..dfef4364965 100644
--- a/app/serializers/pipeline_details_entity.rb
+++ b/app/serializers/pipeline_details_entity.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
class PipelineDetailsEntity < PipelineEntity
+ expose :flags do
+ expose :latest?, as: :latest
+ end
+
expose :details do
- expose :ordered_stages, as: :stages, using: StageEntity
expose :artifacts, using: BuildArtifactEntity
expose :manual_actions, using: BuildActionEntity
expose :scheduled_actions, using: BuildActionEntity
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 8fe5df81e6c..9ef93b2387f 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -20,7 +20,6 @@ class PipelineEntity < Grape::Entity
end
expose :flags do
- expose :latest?, as: :latest
expose :stuck?, as: :stuck
expose :auto_devops_source?, as: :auto_devops
expose :merge_request_event?, as: :merge_request
@@ -34,6 +33,7 @@ class PipelineEntity < Grape::Entity
expose :details do
expose :detailed_status, as: :status, with: DetailedStatusEntity
+ expose :ordered_stages, as: :stages, using: StageEntity
expose :duration
expose :finished_at
end