Remove N+1 queries in /admin/projects page
This commit is contained in:
parent
ea5221aeb3
commit
48f0eff37a
|
@ -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
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue