summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2018-07-16 14:57:08 +0200
committerJacob Vosmaer <jacob@gitlab.com>2018-07-16 14:57:08 +0200
commitab631a18ea100fc5738693e8865ace3986db4fdf (patch)
tree74dc1dea9e79e52dd0772ae4e1ef78346f740f60
parentf705a62e01f791b3c5ba5176c111c13ff4cdd34b (diff)
downloadgitlab-ce-gitaly-mandatory-20180716-jv.tar.gz
Try to fence of gitaly n+1gitaly-mandatory-20180716-jv
-rw-r--r--app/models/project.rb10
1 files 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