diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-29 00:09:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-29 00:09:15 +0300 |
commit | 8831c2df7fa3f1bb567e284e4b8c0a4f441e74b3 (patch) | |
tree | 36b1b430075ff6e63524be14585dbb614e893e8c /app/models/group.rb | |
parent | 1c8fa70f9d0818e2a82089c8643a6e455bca47fd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index a5337f19b38..d6a4af5af15 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -406,11 +406,15 @@ class Group < Namespace end def ci_variables_for(ref, project) - list_of_ids = [self] + ancestors - variables = Ci::GroupVariable.where(group: list_of_ids) - variables = variables.unprotected unless project.protected_for?(ref) - variables = variables.group_by(&:group_id) - list_of_ids.reverse.flat_map { |group| variables[group.id] }.compact + cache_key = "ci_variables_for:group:#{self&.id}:project:#{project&.id}:ref:#{ref}" + + ::Gitlab::SafeRequestStore.fetch(cache_key) do + list_of_ids = [self] + ancestors + variables = Ci::GroupVariable.where(group: list_of_ids) + variables = variables.unprotected unless project.protected_for?(ref) + variables = variables.group_by(&:group_id) + list_of_ids.reverse.flat_map { |group| variables[group.id] }.compact + end end def group_member(user) |