summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-07-19 21:52:31 -0700
committerStan Hu <stanhu@gmail.com>2016-07-26 15:33:05 -0700
commitd1ea2bca61dff21948024d897e1d4475123a10e8 (patch)
treedb9a7093c70ece66eb66b09bf7d6288246ae25cd /app/controllers
parent95efb6f1163b7c2c40d03ddd834016905fc45b50 (diff)
downloadgitlab-ce-d1ea2bca61dff21948024d897e1d4475123a10e8.tar.gz
Optimize maximum user access level lookup in loading of notes
NotesHelper#note_editable? and ProjectTeam#human_max_access currently take about 16% of the load time of an issue page. This MR preloads the maximum access level of users for all notes in issues and merge requests with several queries instead of one per user and caches the result in RequestStore.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/issues_controller.rb3
-rw-r--r--app/controllers/projects/merge_requests_controller.rb3
2 files changed, 6 insertions, 0 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index fa663c9bda4..16ed7c2b6b4 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -1,4 +1,5 @@
class Projects::IssuesController < Projects::ApplicationController
+ include NotesHelper
include ToggleSubscriptionAction
include IssuableActions
include ToggleAwardEmoji
@@ -70,6 +71,8 @@ class Projects::IssuesController < Projects::ApplicationController
@note = @project.notes.new(noteable: @issue)
@noteable = @issue
+ preload_max_access_for_authors(@notes, @project) if @notes
+
respond_to do |format|
format.html
format.json do
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 594a61464b9..da1b9c3e48a 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -3,6 +3,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
include DiffForPath
include DiffHelper
include IssuableActions
+ include NotesHelper
include ToggleAwardEmoji
before_action :module_enabled
@@ -385,6 +386,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@project_wiki,
@ref
)
+
+ preload_max_access_for_authors(@notes, @project) if @notes
end
def define_widget_vars