throw error on counts/posts endpoint during a timeout (#2170)

This commit is contained in:
Albert Yi
2018-09-19 13:34:50 -07:00
parent 2f17082e73
commit ed5b2ad443
3 changed files with 13 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ class Post < ApplicationRecord
class RevertError < Exception ; end
class SearchError < Exception ; end
class DeletionError < Exception ; end
class TimeoutError < Exception ; end
# Tags to copy when copying notes.
NOTE_COPY_TAGS = %w[translated partially_translated check_translation translation_request reverse_translation]
@@ -1202,6 +1203,10 @@ class Post < ApplicationRecord
if count.nil?
# give up
if options[:raise_on_timeout]
raise TimeoutError.new("timed out")
end
count = Danbooru.config.blank_tag_search_fast_count
else
set_count_in_cache(tags, count)