diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index d9dbd5608d6..08a664ad4bf 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -13,16 +13,18 @@ class PipelineSerializer < BaseSerializer def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) - resource = resource.includes(:pending_builds, + project_includes = [ { namespace: :route }, :route ] + resource = resource.includes( :retryable_builds, :cancelable_statuses, - :manual_actions, - :artifacts, - :trigger_requests) - resource = resource.includes(pending_builds: :project) - resource = resource.includes(project: :namespace) - resource = resource.includes(manual_actions: { project: :namespace }) - resource = resource.includes(artifacts: { project: :namespace }) + :trigger_requests + ) + resource = resource.includes( + project: project_includes, + pending_builds: [:project], + manual_actions: { project: project_includes }, + artifacts: { project: project_includes } + ) end if paginated? diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb index 997f40662c5..75cfd000809 100644 --- a/spec/serializers/pipeline_serializer_spec.rb +++ b/spec/serializers/pipeline_serializer_spec.rb @@ -112,7 +112,7 @@ describe PipelineSerializer do it "verifies number of queries" do recorded = ActiveRecord::QueryRecorder.new { subject } - expect(recorded.count).to be_within(10).of(230) + expect(recorded.count).to be_within(10).of(93) expect(recorded.cached_count).to be_within(5).of(5) end