From 50ae15469e078331cd83e04caa3fc9397a42536b Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 30 May 2014 00:02:23 -0400 Subject: [PATCH] fixes #1924 --- app/controllers/counts_controller.rb | 2 +- app/models/post.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/counts_controller.rb b/app/controllers/counts_controller.rb index 9f5b16285..91f2ea9ec 100644 --- a/app/controllers/counts_controller.rb +++ b/app/controllers/counts_controller.rb @@ -2,6 +2,6 @@ class CountsController < ApplicationController respond_to :xml, :json def posts - @count = Post.fast_count(params[:tags]) + @count = Post.fast_count(params[:tags], :statement_timeout => CurrentUser.user.statement_timeout) end end diff --git a/app/models/post.rb b/app/models/post.rb index dd022c88a..77755829b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -796,7 +796,7 @@ class Post < ActiveRecord::Base "pfc:#{Cache.sanitize(tags)}" end - def fast_count(tags = "") + def fast_count(tags = "", options = {}) tags = tags.to_s.strip if tags.blank? && Danbooru.config.blank_tag_search_fast_count @@ -804,12 +804,12 @@ class Post < ActiveRecord::Base elsif tags =~ /^rating:\S+$/ count = Danbooru.config.blank_tag_search_fast_count elsif tags =~ /(?:#{Tag::METATAGS}):/ - count = fast_count_search(tags) + count = fast_count_search(tags, options) else count = get_count_from_cache(tags) if count.to_i == 0 - count = fast_count_search(tags) + count = fast_count_search(tags, options) end end @@ -818,8 +818,8 @@ class Post < ActiveRecord::Base 0 end - def fast_count_search(tags) - count = Post.with_timeout(500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do + def fast_count_search(tags, options = {}) + count = Post.with_timeout(options[:statement_timeout] || 500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do Post.tag_match(tags).count end if count > 0