Commit 227a664e authored by Kamil Trzcinski's avatar Kamil Trzcinski

Next round

parent 93f9e71b
......@@ -13,18 +13,15 @@ class PipelineSerializer < BaseSerializer
def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation)
project_includes = [ { namespace: :route }, :route ]
resource = resource.includes(
resource = resource.includes([
:retryable_builds,
:cancelable_statuses,
:trigger_requests
)
resource = resource.includes(
project: project_includes,
pending_builds: [:project],
manual_actions: { project: project_includes },
artifacts: { project: project_includes }
)
:trigger_requests,
:project,
{ pending_builds: :project },
{ manual_actions: :project },
{ artifacts: :project }
])
end
if paginated?
......
......@@ -96,6 +96,7 @@ describe PipelineSerializer do
context 'number of queries' do
let(:resource) { Ci::Pipeline.all }
let(:project) { create(:empty_project) }
before do
Ci::Pipeline::AVAILABLE_STATUSES.each do |status|
......@@ -112,12 +113,12 @@ describe PipelineSerializer do
it "verifies number of queries" do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(10).of(93)
expect(recorded.cached_count).to be_within(5).of(5)
expect(recorded.count).to be_within(1).of(50)
expect(recorded.cached_count).to eq(0)
end
def create_pipeline(status)
create(:ci_empty_pipeline, status: status).tap do |pipeline|
create(:ci_empty_pipeline, project: project, status: status).tap do |pipeline|
Ci::Build::AVAILABLE_STATUSES.each do |status|
create_build(pipeline, status, status)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment