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.

25 lines
818 B

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. # Base Application
  2. class ApplicationController < ActionController::Base
  3. MAX_DURATION_TO_COMPLETE_IN_SECONDS = 3
  4. around_action do |_, action|
  5. start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  6. begin
  7. action.call
  8. ensure
  9. duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
  10. if duration > MAX_DURATION_TO_COMPLETE_IN_SECONDS
  11. logger.warn('processing took too long to complete, please review your code as asynchronous job!',
  12. duration: duration * 1_000)
  13. end
  14. end
  15. end
  16. def current_user
  17. return session['user_id'] if session['user_id']
  18. return unless session['warden.user.user.key']
  19. logger.info "devise user <#{session['warden.user.user.key'][0][0]}> loaded first time in session"
  20. session['user_id'] = super
  21. end
  22. end