summaryrefslogtreecommitdiff
path: root/app/serializers/pipeline_serializer.rb
diff options
context:
space:
mode:
authorMarcia Ramos <virtua.creative@gmail.com>2019-04-10 17:05:46 +0100
committerMarcia Ramos <virtua.creative@gmail.com>2019-04-10 17:05:46 +0100
commitcbd6841cac8185f181a5dcec33704f6e7c040732 (patch)
tree423bbc4fb873ab51590d0be4ae594769c80b739b /app/serializers/pipeline_serializer.rb
parent3402f8c817e9798eed9d86555f3f85fd10f49abf (diff)
parent490b31f740d23b54a62588cd9fd0e0cf7fdd9370 (diff)
downloadgitlab-ce-docs-pages-intro.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into docs-pages-introdocs-pages-intro
Diffstat (limited to 'app/serializers/pipeline_serializer.rb')
-rw-r--r--app/serializers/pipeline_serializer.rb40
1 files changed, 23 insertions, 17 deletions
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index dbbeca9431d..95d73c6422d 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -7,23 +7,7 @@ class PipelineSerializer < BaseSerializer
# rubocop: disable CodeReuse/ActiveRecord
def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation)
- resource = resource.preload([
- :stages,
- :retryable_builds,
- :cancelable_statuses,
- :trigger_requests,
- :manual_actions,
- :scheduled_actions,
- :artifacts,
- :merge_request,
- {
- pending_builds: :project,
- project: [:route, { namespace: :route }],
- artifacts: {
- project: [:route, { namespace: :route }]
- }
- }
- ])
+ resource = resource.preload(preloaded_relations)
end
if paginated?
@@ -51,4 +35,26 @@ class PipelineSerializer < BaseSerializer
data = represent(resource, { only: [{ details: [:stages] }], preload: true })
data.dig(:details, :stages) || []
end
+
+ private
+
+ def preloaded_relations
+ [
+ :stages,
+ :retryable_builds,
+ :cancelable_statuses,
+ :trigger_requests,
+ :manual_actions,
+ :scheduled_actions,
+ :artifacts,
+ :merge_request,
+ {
+ pending_builds: :project,
+ project: [:route, { namespace: :route }],
+ artifacts: {
+ project: [:route, { namespace: :route }]
+ }
+ }
+ ]
+ end
end