fixes #1924
This commit is contained in:
@@ -2,6 +2,6 @@ class CountsController < ApplicationController
|
|||||||
respond_to :xml, :json
|
respond_to :xml, :json
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
@count = Post.fast_count(params[:tags])
|
@count = Post.fast_count(params[:tags], :statement_timeout => CurrentUser.user.statement_timeout)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ class Post < ActiveRecord::Base
|
|||||||
"pfc:#{Cache.sanitize(tags)}"
|
"pfc:#{Cache.sanitize(tags)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fast_count(tags = "")
|
def fast_count(tags = "", options = {})
|
||||||
tags = tags.to_s.strip
|
tags = tags.to_s.strip
|
||||||
|
|
||||||
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
|
||||||
@@ -804,12 +804,12 @@ class Post < ActiveRecord::Base
|
|||||||
elsif tags =~ /^rating:\S+$/
|
elsif tags =~ /^rating:\S+$/
|
||||||
count = Danbooru.config.blank_tag_search_fast_count
|
count = Danbooru.config.blank_tag_search_fast_count
|
||||||
elsif tags =~ /(?:#{Tag::METATAGS}):/
|
elsif tags =~ /(?:#{Tag::METATAGS}):/
|
||||||
count = fast_count_search(tags)
|
count = fast_count_search(tags, options)
|
||||||
else
|
else
|
||||||
count = get_count_from_cache(tags)
|
count = get_count_from_cache(tags)
|
||||||
|
|
||||||
if count.to_i == 0
|
if count.to_i == 0
|
||||||
count = fast_count_search(tags)
|
count = fast_count_search(tags, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -818,8 +818,8 @@ class Post < ActiveRecord::Base
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
def fast_count_search(tags)
|
def fast_count_search(tags, options = {})
|
||||||
count = Post.with_timeout(500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do
|
count = Post.with_timeout(options[:statement_timeout] || 500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do
|
||||||
Post.tag_match(tags).count
|
Post.tag_match(tags).count
|
||||||
end
|
end
|
||||||
if count > 0
|
if count > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user