diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-06 18:57:02 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-06 18:57:02 +0200 |
commit | 040eeb1039b4298ea56a670a0a4ae511288806d6 (patch) | |
tree | 6777d4d6c4fb1322f0d6ef7c4d2a59195aef3255 /lib | |
parent | de9eca0af65e8fd235aed8c9ea598f16562956e7 (diff) | |
download | gitlab-ce-040eeb1039b4298ea56a670a0a4ae511288806d6.tar.gz |
Allow to enable the Performance Bar for a group from the admin area
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/performance_bar.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb index f48d0506994..aa033571de0 100644 --- a/lib/gitlab/performance_bar.rb +++ b/lib/gitlab/performance_bar.rb @@ -1,27 +1,29 @@ module Gitlab module PerformanceBar + include Gitlab::CurrentSettings + ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids'.freeze # The time (in seconds) after which a set of allowed user IDs is expired # automatically. ALLOWED_USER_IDS_TIME_TO_LIVE = 10.minutes def self.enabled?(current_user = nil) - Feature.enabled?(:gitlab_performance_bar, current_user) + Feature.enabled?(:performance_bar, current_user) end def self.allowed_user?(user) - return false unless allowed_group_name + return false unless allowed_group_id allowed_user_ids.include?(user.id) end - def self.allowed_group_name - Gitlab.config.performance_bar.allowed_group + def self.allowed_group_id + current_application_settings.performance_bar_allowed_group_id end def self.allowed_user_ids - Rails.cache.fetch(cache_key, expires_in: ALLOWED_USER_IDS_TIME_TO_LIVE) do - group = Group.find_by_full_path(allowed_group_name) + Rails.cache.fetch(ALLOWED_USER_IDS_KEY, expires_in: ALLOWED_USER_IDS_TIME_TO_LIVE) do + group = Group.find_by_id(allowed_group_id) if group GroupMembersFinder.new(group).execute.pluck(:user_id) @@ -31,8 +33,8 @@ module Gitlab end end - def self.cache_key - "#{ALLOWED_USER_IDS_KEY}:#{allowed_group_name}" + def self.expire_allowed_user_ids_cache + Rails.cache.delete(ALLOWED_USER_IDS_KEY) end end end |