More fixes for #1865

* Reltag calculator
* Artist default urls (fixes #1149)
* Post count cache
This commit is contained in:
Toks
2013-07-25 19:08:43 -04:00
parent ce05505699
commit c2bd4bedc9
3 changed files with 9 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
class RelatedTagCalculator class RelatedTagCalculator
def self.find_tags(tag, limit) def self.find_tags(tag, limit)
Post.with_timeout(5_000, []) do CurrentUser.without_safe_mode do
Post.tag_match(tag).limit(limit).select("posts.tag_string").reorder("posts.md5").map(&:tag_string) Post.with_timeout(5_000, []) do
Post.tag_match(tag).limit(limit).select("posts.tag_string").reorder("posts.md5").map(&:tag_string)
end
end end
end end

View File

@@ -128,11 +128,8 @@ class Artist < ActiveRecord::Base
Artist.new.tap do |artist| Artist.new.tap do |artist|
if params[:name] if params[:name]
artist.name = params[:name] artist.name = params[:name]
if CurrentUser.user.is_gold? post = CurrentUser.without_safe_mode do
# below gold users are limited to two tags Post.tag_match("source:http #{artist.name}").first
post = Post.tag_match("source:http #{artist.name} status:any").first
else
post = Post.tag_match("source:http #{artist.name}").first
end end
unless post.nil? || post.source.blank? unless post.nil? || post.source.blank?
artist.url_string = post.source artist.url_string = post.source

View File

@@ -728,7 +728,9 @@ class Post < ActiveRecord::Base
def fast_count_search(tags) def fast_count_search(tags)
count = Post.with_timeout(500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do count = Post.with_timeout(500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do
Post.tag_match(tags).count CurrentUser.without_safe_mode do
Post.tag_match(tags).count
end
end end
if count > 0 if count > 0
set_count_in_cache(tags, count) set_count_in_cache(tags, count)