diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-28 18:50:44 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-29 18:54:54 +0300 |
commit | a0527ab806b005eeffd3b4f983e33c4bd76ce6b3 (patch) | |
tree | 046c4d34775d4ce9b2e89c1942b5344e2a49175b /app/models/protected_tag.rb | |
parent | 52f5259ae40cfd868c6412ba10e28dc83877afbb (diff) |
Only load branch names for protected branch checks
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_tag.rb')
-rw-r--r-- | app/models/protected_tag.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb index f38109c0e52..42a9bcf7723 100644 --- a/app/models/protected_tag.rb +++ b/app/models/protected_tag.rb @@ -5,6 +5,8 @@ class ProtectedTag < ActiveRecord::Base protected_ref_access_levels :create def self.protected?(project, ref_name) - self.matching(ref_name, protected_refs: project.protected_tags).present? + refs = project.protected_tags.select(:name) + + self.matching(ref_name, protected_refs: refs).present? end end |