summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2019-04-09 13:10:31 +0200
committerMatija Čupić <matteeyah@gmail.com>2019-04-09 13:24:27 +0200
commit726f142dd233d82da6a7e60eaee30342ceecfbaf (patch)
tree2a978407660eed6c69a6adf9483ac74e033c654c /app/serializers
parent7b0f9f82f65dc62d451c962a9d3f6a18b4572415 (diff)
downloadgitlab-ce-726f142dd233d82da6a7e60eaee30342ceecfbaf.tar.gz
Diffstat (limited to 'app/serializers')
-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