Commit bd846f7d authored by Shinya Maeda's avatar Shinya Maeda

Use ancestors for avoiding N queries

parent e255e4de
...@@ -250,10 +250,9 @@ class Group < Namespace ...@@ -250,10 +250,9 @@ class Group < Namespace
end end
def secret_variables_for(ref, project) def secret_variables_for(ref, project)
variables = [] list_of_ids = ([self] + ancestors).map { |l| l.id }
variables += parent.secret_variables_for(ref, project) if has_parent? variables = Ci::GroupVariable.where("group_id IN (#{list_of_ids.join(", ")})")
variables += project.protected_for?(ref) ? self.variables : self.variables.unprotected project.protected_for?(ref) ? variables : variables.unprotected
variables
end end
protected protected
......
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