Commit 5c68fa66 authored by Shinya Maeda's avatar Shinya Maeda

secret_variables_for: rails readability versino

parent 5cb45b6a
...@@ -250,17 +250,11 @@ class Group < Namespace ...@@ -250,17 +250,11 @@ class Group < Namespace
end end
def secret_variables_for(ref, project) def secret_variables_for(ref, project)
list_of_ids = ([self] + ancestors).map { |l| l.id } list_of_ids = [self] + ancestors
variables = Ci::GroupVariable.where(group: list_of_ids)
order = list_of_ids.map.with_index do |id, index| variables = variables.unprotected unless project.protected_for?(ref)
"WHEN #{id} THEN #{index}" variables = variables.group_by(&:group_id)
end.join("\n") list_of_ids.reverse.map { |group| variables[group.id] }.compact.flatten
variables = Ci::GroupVariable
.where("group_id IN (#{list_of_ids.join(", ")})")
.order("CASE group_id #{order} END DESC")
project.protected_for?(ref) ? variables : variables.unprotected
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