diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 09:09:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 09:09:06 +0300 |
commit | cefe554b7ce2d0b52f9de855be832a47c2bc24ab (patch) | |
tree | 74c1ad2f688afd2f806aaf94e73e0bcd128cea00 /app/serializers | |
parent | 5ee120f46740efac7b8a460d7a92e4da82f4fb0b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/pipeline_details_entity.rb | 7 | ||||
-rw-r--r-- | app/serializers/pipeline_serializer.rb | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/serializers/pipeline_details_entity.rb b/app/serializers/pipeline_details_entity.rb index a4ab1d399bc..a58278cf4ef 100644 --- a/app/serializers/pipeline_details_entity.rb +++ b/app/serializers/pipeline_details_entity.rb @@ -8,7 +8,12 @@ class PipelineDetailsEntity < PipelineEntity end expose :details do - expose :artifacts, using: BuildArtifactEntity + expose :artifacts do |pipeline, options| + rel = pipeline.artifacts + rel = rel.eager_load_job_artifacts_archive if options.fetch(:preload_job_artifacts_archive, true) + + BuildArtifactEntity.represent(rel, options) + end expose :manual_actions, using: BuildActionEntity expose :scheduled_actions, using: BuildActionEntity end diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index 58df62dfea5..3ad9f2bc0bf 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -7,6 +7,10 @@ class PipelineSerializer < BaseSerializer # rubocop: disable CodeReuse/ActiveRecord def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) + # We don't want PipelineDetailsEntity to preload the job_artifacts_archive + # because we do it with preloaded_relations in a more optimal way + # if the given resource is a collection of multiple pipelines. + opts[:preload_job_artifacts_archive] = false resource = resource.preload(preloaded_relations) end |