search: refactor fast_count to return nil on timeout.
* Refactor fast_count to return nil instead of 1,000,000 if the exact count times out. * Remove the estimate_post_counts and blank_tag_search_fast_count global config options. * Replace the hardcoded post count estimates inside fast_count with a method that parses Postgres's estimated row count from EXPLAIN. * /counts/posts.json: ** Remove the `raise_on_timeout` parameter. ** Add an `estimate_count=<true|false>` parameter. ** Return null instead of 1,000,000 if the exact count times out.
This commit is contained in:
@@ -84,7 +84,7 @@ module PostSets
|
||||
def get_post_count
|
||||
if %w(json atom xml).include?(format.downcase)
|
||||
# no need to get counts for formats that don't use a paginator
|
||||
return Danbooru.config.blank_tag_search_fast_count
|
||||
nil
|
||||
else
|
||||
query.fast_count
|
||||
end
|
||||
@@ -103,15 +103,11 @@ module PostSets
|
||||
if is_random?
|
||||
temp = get_random_posts
|
||||
else
|
||||
temp = query.build.paginate(page, count: post_count, limit: per_page)
|
||||
temp = query.build.paginate(page, count: post_count, search_count: !post_count.nil?, limit: per_page)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def unknown_post_count?
|
||||
post_count == Danbooru.config.blank_tag_search_fast_count
|
||||
end
|
||||
|
||||
def hide_from_crawler?
|
||||
return true if current_page > 1
|
||||
return false if query.is_empty_search? || query.is_simple_tag? || query.is_metatag?(:order, :rank)
|
||||
|
||||
Reference in New Issue
Block a user