fixes #2432, fix tests
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user