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:
evazion
2020-05-07 20:20:12 -05:00
parent d3e4ac7c17
commit 41c6c882c2
9 changed files with 64 additions and 121 deletions

View File

@@ -136,10 +136,6 @@ class PostTest < ActiveSupport::TestCase
end
context "Deleting a post" do
setup do
Danbooru.config.stubs(:blank_tag_search_fast_count).returns(nil)
end
context "that is status locked" do
setup do
@post = FactoryBot.create(:post, is_status_locked: true)