* 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.
10 lines
396 B
Ruby
10 lines
396 B
Ruby
class CountsController < ApplicationController
|
|
respond_to :xml, :json
|
|
|
|
def posts
|
|
estimate_count = params.fetch(:estimate_count, "true").truthy?
|
|
skip_cache = params.fetch(:skip_cache, "false").truthy?
|
|
@count = PostQueryBuilder.new(params[:tags], CurrentUser.user).fast_count(timeout: CurrentUser.statement_timeout, estimate_count: estimate_count, skip_cache: skip_cache)
|
|
end
|
|
end
|