Browse Source

max action duration

main
pvincent 1 year ago
parent
commit
72e8773ccb
  1. 1
      README.md
  2. 4
      app/controllers/application_controller.rb
  3. 2
      app/views/main/about.html.erb

1
README.md

@ -6,3 +6,4 @@
* [x] LXD aware (through remote ssh)
* [x] Rufo Formatter
* [x] Semantic Logging (efficient for dark theme)
* [x] Max duration to complete in order to prevent long action

4
app/controllers/application_controller.rb

@ -1,6 +1,8 @@
class ApplicationController < ActionController::Base
MAX_DURATION_TO_COMPLETE_IN_SECONDS = 3
around_action do |_, action|
logger.measure_error "Took too long to complete, please review your code as asynchronous task", min_duration: 3000 do
logger.measure_error "Took too long to complete, please review your code as asynchronous task", min_duration: MAX_DURATION_TO_COMPLETE_IN_SECONDS * 1000 do
action.call
end
end

2
app/views/main/about.html.erb

@ -1,2 +1,2 @@
<h1>Main#about</h1>
<p>Find me in app/views/main/about.html.erb</p>
This page takes a while to complete
Loading…
Cancel
Save