Merge branch 'sh-admin-projects-remove-n-plus-one' into 'master'

Remove N+1 queries in /admin/projects page

See merge request gitlab-org/gitlab-ce!17834
This commit is contained in:
Robert Speicher 2018-03-19 16:01:40 +00:00
commit a520ab64db
2 changed files with 11 additions and 0 deletions

View File

@ -16,6 +16,7 @@ class Admin::ProjectsFinder
items = by_archived(items)
items = by_personal(items)
items = by_name(items)
items = items.includes(namespace: [:owner])
sort(items).page(params[:page])
end

View File

@ -31,5 +31,15 @@ describe Admin::ProjectsController do
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
it 'does not have N+1 queries', :use_clean_rails_memory_store_caching, :request_store do
get :index
control_count = ActiveRecord::QueryRecorder.new { get :index }.count
create(:project)
expect { get :index }.not_to exceed_query_limit(control_count)
end
end
end