Commit a520ab64 authored by Robert Speicher's avatar Robert Speicher

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
parents 736541f5 48f0eff3
...@@ -16,6 +16,7 @@ class Admin::ProjectsFinder ...@@ -16,6 +16,7 @@ class Admin::ProjectsFinder
items = by_archived(items) items = by_archived(items)
items = by_personal(items) items = by_personal(items)
items = by_name(items) items = by_name(items)
items = items.includes(namespace: [:owner])
sort(items).page(params[:page]) sort(items).page(params[:page])
end end
......
...@@ -31,5 +31,15 @@ describe Admin::ProjectsController do ...@@ -31,5 +31,15 @@ describe Admin::ProjectsController do
expect(response.body).not_to match(pending_delete_project.name) expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name) expect(response.body).to match(project.name)
end 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
end 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