Commit accb9488 authored by Maxime Orefice's avatar Maxime Orefice

Remove tests_total_count from PipelineEntity

This MR stops exposing tests_total_count data from our
PipelineEntity as we don't use it in our frontend.
It also starts memoizing test_report_summary.

Apply code review feedback
parent 06a3f976
...@@ -869,7 +869,9 @@ module Ci ...@@ -869,7 +869,9 @@ module Ci
end end
def test_report_summary def test_report_summary
Gitlab::Ci::Reports::TestReportSummary.new(latest_builds_report_results) strong_memoize(:test_report_summary) do
Gitlab::Ci::Reports::TestReportSummary.new(latest_builds_report_results)
end
end end
def test_reports def test_reports
......
...@@ -85,10 +85,6 @@ class PipelineEntity < Grape::Entity ...@@ -85,10 +85,6 @@ class PipelineEntity < Grape::Entity
pipeline.failed_builds pipeline.failed_builds
end end
expose :tests_total_count do |pipeline|
pipeline.test_report_summary.total[:count]
end
private private
alias_method :pipeline, :object alias_method :pipeline, :object
......
...@@ -43,7 +43,7 @@ RSpec.describe Projects::PipelinesController do ...@@ -43,7 +43,7 @@ RSpec.describe Projects::PipelinesController do
end end
end end
it 'executes N+1 queries' do it 'does not execute N+1 queries' do
get_pipelines_index_json get_pipelines_index_json
control_count = ActiveRecord::QueryRecorder.new do control_count = ActiveRecord::QueryRecorder.new do
...@@ -53,7 +53,7 @@ RSpec.describe Projects::PipelinesController do ...@@ -53,7 +53,7 @@ RSpec.describe Projects::PipelinesController do
create_all_pipeline_types create_all_pipeline_types
# There appears to be one extra query for Pipelines#has_warnings? for some reason # There appears to be one extra query for Pipelines#has_warnings? for some reason
expect { get_pipelines_index_json }.not_to exceed_query_limit(control_count + 7) expect { get_pipelines_index_json }.not_to exceed_query_limit(control_count + 1)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['pipelines'].count).to eq 12 expect(json_response['pipelines'].count).to eq 12
end end
......
...@@ -260,13 +260,5 @@ RSpec.describe PipelineEntity do ...@@ -260,13 +260,5 @@ RSpec.describe PipelineEntity do
end end
end end
end end
context 'when pipeline has build report results' do
let(:pipeline) { create(:ci_pipeline, :with_report_results, project: project, user: user) }
it 'exposes tests total count' do
expect(subject[:tests_total_count]).to eq(2)
end
end
end end
end end
...@@ -155,7 +155,7 @@ RSpec.describe PipelineSerializer do ...@@ -155,7 +155,7 @@ RSpec.describe PipelineSerializer do
it 'verifies number of queries', :request_store do it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject } recorded = ActiveRecord::QueryRecorder.new { subject }
expected_queries = Gitlab.ee? ? 46 : 43 expected_queries = Gitlab.ee? ? 43 : 40
expect(recorded.count).to be_within(2).of(expected_queries) expect(recorded.count).to be_within(2).of(expected_queries)
expect(recorded.cached_count).to eq(0) expect(recorded.cached_count).to eq(0)
......
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