diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 02:27:06 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-07 15:35:12 +0900 |
commit | bd846f7d93d1c7fd1d7ffdf097be88cf4ddf6581 (patch) | |
tree | faae962a66f3ecc4fa84c5d60400c8cea8e17a91 /app | |
parent | e255e4de6943f419e4d1137104f990a120e3f72a (diff) | |
download | gitlab-ce-bd846f7d93d1c7fd1d7ffdf097be88cf4ddf6581.tar.gz |
Use ancestors for avoiding N queries
Diffstat (limited to 'app')
-rw-r--r-- | app/models/group.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index f625b8c250c..480b90b279e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -250,10 +250,9 @@ class Group < Namespace end def secret_variables_for(ref, project) - variables = [] - variables += parent.secret_variables_for(ref, project) if has_parent? - variables += project.protected_for?(ref) ? self.variables : self.variables.unprotected - variables + list_of_ids = ([self] + ancestors).map { |l| l.id } + variables = Ci::GroupVariable.where("group_id IN (#{list_of_ids.join(", ")})") + project.protected_for?(ref) ? variables : variables.unprotected end protected |