Files
danbooru/app/controllers/counts_controller.rb
evazion 6edff247f2 search: replace calls to PostQueryBuilder#fast_count with PostQuery#fast_count.
Prepare a few more places for the new tag search parser.
2022-03-30 01:37:11 -05:00

18 lines
634 B
Ruby

# frozen_string_literal: true
class CountsController < ApplicationController
respond_to :html, :xml, :json
def posts
estimate_count = params.fetch(:estimate_count, "true").truthy?
skip_cache = params.fetch(:skip_cache, "false").truthy?
@count = PostQuery.new(params[:tags], current_user: CurrentUser.user, tag_limit: CurrentUser.user.tag_query_limit).fast_count(timeout: CurrentUser.statement_timeout, estimate_count: estimate_count, skip_cache: skip_cache)
if request.format.xml?
respond_with({ posts: @count }, root: "counts")
else
respond_with({ counts: { posts: @count }})
end
end
end