You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
849 B

# frozen_string_literal: true
# Base Application
class ApplicationController < ActionController::Base
MAX_DURATION_TO_COMPLETE_IN_SECONDS = 3
around_action do |_, action|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
begin
action.call
ensure
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
if duration > MAX_DURATION_TO_COMPLETE_IN_SECONDS
logger.warn('processing took too long to complete, please review your code as asynchronous job!',
duration: duration * 1_000)
end
end
end
def current_user
return session['user_id'] if session['user_id']
return unless session['warden.user.user.key']
logger.info "devise user <#{session['warden.user.user.key'][0][0]}> loaded first time in session"
session['user_id'] = super
end
end