2017-06-21 10:59:13 -04:00
|
|
|
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-01-16 13:13:31 -05:00
|
|
|
RequestStore.fetch(:peek_enabled) { cookie_or_default_value }
|
2017-06-21 10:59:13 -04:00
|
|
|
else
|
2018-01-16 13:13:31 -05:00
|
|
|
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-06-21 10:59:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|