From 82564355e6d2d0d8afd346eebf1f52b0bcb4cd06 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 16 Dec 2019 13:38:06 -0600 Subject: [PATCH] Add better error page for database timeouts. --- app/controllers/application_controller.rb | 2 +- app/views/static/search_timeout.html.erb | 55 +++++++++++++++++++++++ app/views/user_upgrades/new.html.erb | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 app/views/static/search_timeout.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b1359ffc2..9bee200f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base def rescue_exception(exception) case exception when ActiveRecord::QueryCanceled - render_error_page(500, exception, message: "The database timed out running your query.") + render_error_page(500, exception, template: "static/search_timeout", message: "The database timed out running your query.") when ActionController::BadRequest render_error_page(400, exception) when SessionLoader::AuthenticationFailure diff --git a/app/views/static/search_timeout.html.erb b/app/views/static/search_timeout.html.erb new file mode 100644 index 000000000..2c65343cd --- /dev/null +++ b/app/views/static/search_timeout.html.erb @@ -0,0 +1,55 @@ +
+
+

Search Timeout

+ +

Your search took too long to execute and was cancelled.

+ +
Why did this happen?
+ +

+ Some kinds of searches are slower than others. If your search is too slow + it may be cancelled. Usually this happens when your search is too + complex, or when there aren't many recent posts matching your search. +

+ + <% if params[:controller] == "posts" && params[:action] == "index" && params[:tags].present? %> +
What can I do?
+ +

Try changing your search:

+ +

+ + + + + + + + + + + + + +
<%= link_to "#{params[:tags]} age:<1month", posts_url(tags: "#{params[:tags]} age:<1month") %>Search recent posts only.
<%= link_to "#{params[:tags]} order:score", posts_url(tags: "#{params[:tags]} order:score") %>Order by score instead of by date.
<%= link_to "#{params[:tags]} limit:5", posts_url(tags: "#{params[:tags]} limit:5") %>Show fewer posts per page.
+

+ <% end %> + + <% if !CurrentUser.is_gold? %> +
Search limits
+ +

+ Members are limited to searches that take up to 3 seconds long. You can + <%= link_to "upgrade your account", new_user_upgrade_path %> to increase + your search limit. Gold users can do searches that take up to 6 seconds + long, and Platinum users can go up to 9 seconds. +

+ <% end %> + + <%= link_to "Go back", :back, rel: "prev" %> +
+
+ +<% content_for(:page_title) do %> + Search Timeout - <%= Danbooru.config.app_name %> +<% end %> diff --git a/app/views/user_upgrades/new.html.erb b/app/views/user_upgrades/new.html.erb index 436249e08..8522f60ca 100644 --- a/app/views/user_upgrades/new.html.erb +++ b/app/views/user_upgrades/new.html.erb @@ -75,7 +75,7 @@ 4 - Database Timeout + Search Timeout 3 sec 6 sec 9 sec