2017-09-10 17:25:29 +05:30
|
|
|
module WithPerformanceBar
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
include Peek::Rblineprof::CustomControllerHelpers
|
|
|
|
end
|
|
|
|
|
|
|
|
def peek_enabled?
|
|
|
|
return false unless Gitlab::PerformanceBar.enabled?(current_user)
|
|
|
|
|
|
|
|
if RequestStore.active?
|
2018-03-17 18:26:18 +05:30
|
|
|
RequestStore.fetch(:peek_enabled) { cookie_or_default_value }
|
2017-09-10 17:25:29 +05:30
|
|
|
else
|
2018-03-17 18:26:18 +05:30
|
|
|
cookie_or_default_value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cookie_or_default_value
|
|
|
|
if cookies[:perf_bar_enabled].present?
|
|
|
|
cookies[:perf_bar_enabled] == 'true'
|
|
|
|
else
|
|
|
|
cookies[:perf_bar_enabled] = 'true' if Rails.env.development?
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|