From cf3be218e17d147cb9b1395af6b968d47b56ce0a Mon Sep 17 00:00:00 2001 From: Adam Niedzielski Date: Fri, 13 Jan 2017 10:12:27 -0500 Subject: [PATCH] Speed up dashboard milestone index by scoping IssuesFinder to user authorized projects It improves performance in dashboard milestone index page by passing a hint to "IssuesFinder". "IssuesFinder" generates a more performant query when it is limited to authorized projects for user. In the dashboard we already limit the projects to these authorized for user (see "Dashboard::ApplicationController#projects"), so we can safely pass this option to "IssuesFinder". --- app/controllers/dashboard/milestones_controller.rb | 4 ++-- app/models/dashboard_milestone.rb | 5 +++++ changelogs/unreleased/speed-up-dashboard-milestone-index.yml | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 app/models/dashboard_milestone.rb create mode 100644 changelogs/unreleased/speed-up-dashboard-milestone-index.yml diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb index 7051652d109..7f506db583f 100644 --- a/app/controllers/dashboard/milestones_controller.rb +++ b/app/controllers/dashboard/milestones_controller.rb @@ -19,11 +19,11 @@ class Dashboard::MilestonesController < Dashboard::ApplicationController private def milestones - @milestones = GlobalMilestone.build_collection(@projects, params) + @milestones = DashboardMilestone.build_collection(@projects, params) end def milestone - @milestone = GlobalMilestone.build(@projects, params[:title]) + @milestone = DashboardMilestone.build(@projects, params[:title]) render_404 unless @milestone end end diff --git a/app/models/dashboard_milestone.rb b/app/models/dashboard_milestone.rb new file mode 100644 index 00000000000..646c1e5ce1a --- /dev/null +++ b/app/models/dashboard_milestone.rb @@ -0,0 +1,5 @@ +class DashboardMilestone < GlobalMilestone + def issues_finder_params + { authorized_only: true } + end +end diff --git a/changelogs/unreleased/speed-up-dashboard-milestone-index.yml b/changelogs/unreleased/speed-up-dashboard-milestone-index.yml new file mode 100644 index 00000000000..ba4ff931ea8 --- /dev/null +++ b/changelogs/unreleased/speed-up-dashboard-milestone-index.yml @@ -0,0 +1,5 @@ +--- +title: Speed up dashboard milestone index by scoping IssuesFinder to user authorized + projects +merge_request: 8524 +author: