Add QueryRecorder to Specs for EnvironmentsFolder and DashboardEnvironmentsSerializer
Add ActiveRecord::QueryRecorder.new
on the specs for EnviromentsFolder
and DashboardEnvironmentsSerializer
.
See discussion at: !18353 (comment 229342541)
Problem to Solve
We need to understand the performance impacts of the current number of SQL queries registered on EnviromentsFolder
and on DashboardEnvironmentsSerializer
, to ensure future iterations respect this number, or even better they improve it.
Proposal
Add spec on DashboardEnviromentsSerializer
and EnviornmentsFolder
called ActiveRecord::QueryRecorder.new
, something along the lines of:
describe 'number of queries' do
subject { environment_folder.find_for_projects(projects) }
context 'with one environment' do
let(:projects) { [create(:project)] }
before do
# we create the data here
end
it 'respects the expected number' do
recorded = ActiveRecord::QueryRecorder.new { subject }
expected_queries = X # number of queries so far
expect(recorded.count).to eq(expected_queries)
end
end
context 'with 20 environments' do # Assuming we paginate environments in a future iteration and we default to 20 per page
let(:projects) { create_list(:project, 20) }
before do
# we create the data here
end
it 'respects the expected number'
end
end
Edited by 🤖 GitLab Bot 🤖