diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-18 19:11:24 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-09-21 22:41:41 +0300 |
commit | 8c2f547e832b4e66fefd7f6baf5de91ee9718d51 (patch) | |
tree | e6629299f46aa9d1527da8f6c5ac1ac4738e42e6 /app | |
parent | c55ce585361f2169f33b0b52080bd622acae6e2a (diff) |
Merge branch 'sh-optimize-discussion-json' into 'master'
Eliminate N+1 queries in loading discussions.json endpoint
Closes #37955
See merge request gitlab-org/gitlab-ce!14327
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 4 | ||||
-rw-r--r-- | app/models/project_team.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index e453b66fe8e..a3ec79a56d9 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -84,9 +84,9 @@ class Projects::IssuesController < Projects::ApplicationController .inc_relations_for_view .includes(:noteable) .fresh - .reject { |n| n.cross_reference_not_visible_for?(current_user) } - prepare_notes_for_rendering(notes) + notes = prepare_notes_for_rendering(notes) + notes = notes.reject { |n| n.cross_reference_not_visible_for?(current_user) } discussions = Discussion.build_collection(notes, @issue) diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 09049824ff7..1d35426050e 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -146,7 +146,7 @@ class ProjectTeam def member?(user, min_access_level = Gitlab::Access::GUEST) return false unless user - user.authorized_project?(project, min_access_level) + max_member_access(user.id) >= min_access_level end def human_max_access(user_id) |