diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-28 19:18:16 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-06 11:18:25 +0200 |
commit | b531616ebad93bb4bd5c82108562731d64a23078 (patch) | |
tree | 28e243462ec090214f3b7f9e49f9b7e28afae38e /lib/gitlab | |
parent | 186048a404b2f5b84f4472a7d05cbb2309b1e9bf (diff) | |
download | gitlab-ce-b531616ebad93bb4bd5c82108562731d64a23078.tar.gz |
Cache PerformanceBar data using RequestStore
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/performance_bar.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb index 2ca2cbeac08..53812633888 100644 --- a/lib/gitlab/performance_bar.rb +++ b/lib/gitlab/performance_bar.rb @@ -5,19 +5,34 @@ module Gitlab end def self.allowed_actor?(actor) - group = allowed_group - return false unless actor&.is_a?(User) && group + return false unless actor.thing&.is_a?(User) && allowed_group - GroupMembersFinder.new(group) - .execute - .where(user_id: actor.id) - .any? + if RequestStore.active? + RequestStore.fetch('performance_bar:user_member_of_allowed_group') do + user_member_of_allowed_group?(actor.thing) + end + else + user_member_of_allowed_group?(actor.thing) + end end def self.allowed_group return nil unless Gitlab.config.performance_bar.allowed_group - Group.by_path(Gitlab.config.performance_bar.allowed_group) + if RequestStore.active? + RequestStore.fetch('performance_bar:allowed_group') do + Group.by_path(Gitlab.config.performance_bar.allowed_group) + end + else + Group.by_path(Gitlab.config.performance_bar.allowed_group) + end + end + + def self.user_member_of_allowed_group?(user) + GroupMembersFinder.new(allowed_group) + .execute + .where(user_id: user.id) + .any? end end end |