From ab631a18ea100fc5738693e8865ace3986db4fdf Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 16 Jul 2018 14:57:08 +0200 Subject: Try to fence of gitaly n+1 --- app/models/project.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index e29bca365a4..4b57aa0242f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2171,10 +2171,12 @@ class Project < ActiveRecord::Base merge_requests = source_of_merge_requests.opened .where(allow_collaboration: true) - if branch_name - merge_requests.find_by(source_branch: branch_name)&.can_be_merged_by?(user) - else - merge_requests.any? { |merge_request| merge_request.can_be_merged_by?(user) } + Gitlab::GitalyClient.allow_n_plus_1_calls do + if branch_name + merge_requests.find_by(source_branch: branch_name)&.can_be_merged_by?(user) + else + merge_requests.any? { |merge_request| merge_request.can_be_merged_by?(user) } + end end end -- cgit v1.2.1