Commit 0459ed26 authored by Gary Holtz's avatar Gary Holtz

Cache `branch_requires_code_owner_approval?`

This saves a few queries during the MR index listing

Changelog: performance
EE: true
parent 06abf977
...@@ -16,7 +16,8 @@ module EE ...@@ -16,7 +16,8 @@ module EE
def branch_requires_code_owner_approval?(project, branch_name) def branch_requires_code_owner_approval?(project, branch_name)
return false unless project.code_owner_approval_required_available? return false unless project.code_owner_approval_required_available?
project.protected_branches.requiring_code_owner_approval.matching(branch_name).any? ::Gitlab::SafeRequestStore["project-#{project.id}-branch-#{branch_name}".to_sym] ||=
project.protected_branches.requiring_code_owner_approval.matching(branch_name).any?
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment