fixes #2432, fix tests

This commit is contained in:
r888888888
2015-07-14 15:13:04 -07:00
parent 2c8cacd50e
commit 6ad6aa44c4
13 changed files with 6809 additions and 841 deletions

View File

@@ -128,12 +128,12 @@ class ForumPost < ActiveRecord::Base
end
def delete!
update_attributes(:is_deleted => true)
update_attribute(:is_deleted, true)
update_topic_updated_at_on_delete
end
def undelete!
update_attributes(:is_deleted => false)
update_attribute(:is_deleted, false)
update_topic_updated_at_on_undelete
end

View File

@@ -1003,6 +1003,7 @@ class Post < ActiveRecord::Base
if CurrentUser.safe_mode?
tags = "#{tags} rating:s".strip
end
if CurrentUser.user && CurrentUser.hide_deleted_posts? && tags !~ /(?:^|\s)(?:-)?status:.+/
tags = "#{tags} -status:deleted".strip
end
@@ -1010,16 +1011,16 @@ class Post < ActiveRecord::Base
"pfc:#{Cache.sanitize(tags)}"
end
def slow_query?(tags)
!CurrentUser.is_gold? && (CurrentUser.safe_mode? || tags.blank? || tags =~ /(?:#{Tag::METATAGS}):/ || tags =~ / /)
end
def fast_count(tags = "", options = {})
tags = tags.to_s.strip
max_count = Danbooru.config.blank_tag_search_fast_count
if tags.blank? && Danbooru.config.blank_tag_search_fast_count
count = Danbooru.config.blank_tag_search_fast_count
elsif tags =~ /^-?rating:\S+$/
count = Danbooru.config.blank_tag_search_fast_count
elsif tags =~ /(?:#{Tag::METATAGS}):/
options[:statement_timeout] = 500
count = fast_count_search(tags, options)
if max_count && slow_query?(tags)
count = max_count
else
count = get_count_from_cache(tags)