summaryrefslogtreecommitdiff
path: root/app/models/protected_branch.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-28 16:50:44 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-29 16:54:54 +0100
commita0527ab806b005eeffd3b4f983e33c4bd76ce6b3 (patch)
tree046c4d34775d4ce9b2e89c1942b5344e2a49175b /app/models/protected_branch.rb
parent52f5259ae40cfd868c6412ba10e28dc83877afbb (diff)
downloadgitlab-ce-a0527ab806b005eeffd3b4f983e33c4bd76ce6b3.tar.gz
Only load branch names for protected branch checksprotected-branches-names
When checking if a branch is protected we don't need all columns of every protected branch row, instead we only care about the names. By using "select" here we reduce the amount of data we need to send over the wire and load into memory.
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r--app/models/protected_branch.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index 89bfc5f9a9c..d28fed11ca8 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -10,7 +10,9 @@ class ProtectedBranch < ActiveRecord::Base
def self.protected?(project, ref_name)
return true if project.empty_repo? && default_branch_protected?
- self.matching(ref_name, protected_refs: project.protected_branches).present?
+ refs = project.protected_branches.select(:name)
+
+ self.matching(ref_name, protected_refs: refs).present?
end
def self.default_branch_protected?