From 72e8773ccbff1a7f70b02bd8eb69fb3dcfbf4a0a Mon Sep 17 00:00:00 2001 From: pvincent Date: Sat, 27 May 2023 13:32:38 +0400 Subject: [PATCH] max action duration --- README.md | 1 + app/controllers/application_controller.rb | 4 +++- app/views/main/about.html.erb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da2720e..3ece999 100644 --- a/README.md +++ b/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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dfd83fa..83d4bf7 100644 --- a/app/controllers/application_controller.rb +++ b/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 diff --git a/app/views/main/about.html.erb b/app/views/main/about.html.erb index 307813b..cd51748 100644 --- a/app/views/main/about.html.erb +++ b/app/views/main/about.html.erb @@ -1,2 +1,2 @@

Main#about

-

Find me in app/views/main/about.html.erb

+This page takes a while to complete