Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb14
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)