diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-04 17:52:26 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-07 13:38:33 +0300 |
commit | bd08fff6c55bc13337b6501ff03bb7787decab68 (patch) | |
tree | da63c1fc8732209674b9b9dca26620d2b35e19e1 | |
parent | ab738645a7b5bba46c8bf50f0780e66befc8bbe2 (diff) |
Eager load project creators for project dashboards
This solves an N+1 query problem where for every project we'd query the
creator separately just to figure out what avatar to display.
-rw-r--r-- | app/controllers/dashboard/projects_controller.rb | 6 | ||||
-rw-r--r-- | changelogs/unreleased/eager-load-project-creators-for-project-dashboards.yml | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index 91c1e4dff79..74fe45e1ff6 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -45,8 +45,10 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController end def load_projects(finder_params) - ProjectsFinder.new(params: finder_params, current_user: current_user) - .execute.includes(:route, namespace: :route) + ProjectsFinder + .new(params: finder_params, current_user: current_user) + .execute + .includes(:route, :creator, namespace: :route) end def load_events diff --git a/changelogs/unreleased/eager-load-project-creators-for-project-dashboards.yml b/changelogs/unreleased/eager-load-project-creators-for-project-dashboards.yml new file mode 100644 index 00000000000..e550e0b2f44 --- /dev/null +++ b/changelogs/unreleased/eager-load-project-creators-for-project-dashboards.yml @@ -0,0 +1,4 @@ +--- +title: Eager load project creators for project dashboards +merge_request: +author: |