From c2bd4bedc9284b390b164afb9eea1f6142d507b4 Mon Sep 17 00:00:00 2001 From: Toks Date: Thu, 25 Jul 2013 19:08:43 -0400 Subject: [PATCH] More fixes for #1865 * Reltag calculator * Artist default urls (fixes #1149) * Post count cache --- app/logical/related_tag_calculator.rb | 6 ++++-- app/models/artist.rb | 7 ++----- app/models/post.rb | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/logical/related_tag_calculator.rb b/app/logical/related_tag_calculator.rb index 595e343fc..2215a6976 100644 --- a/app/logical/related_tag_calculator.rb +++ b/app/logical/related_tag_calculator.rb @@ -1,7 +1,9 @@ class RelatedTagCalculator def self.find_tags(tag, limit) - Post.with_timeout(5_000, []) do - Post.tag_match(tag).limit(limit).select("posts.tag_string").reorder("posts.md5").map(&:tag_string) + CurrentUser.without_safe_mode do + 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 diff --git a/app/models/artist.rb b/app/models/artist.rb index eafb0a7be..89a1cd296 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -128,11 +128,8 @@ class Artist < ActiveRecord::Base Artist.new.tap do |artist| if params[:name] artist.name = params[:name] - if CurrentUser.user.is_gold? - # below gold users are limited to two tags - post = Post.tag_match("source:http #{artist.name} status:any").first - else - post = Post.tag_match("source:http #{artist.name}").first + post = CurrentUser.without_safe_mode do + Post.tag_match("source:http #{artist.name}").first end unless post.nil? || post.source.blank? artist.url_string = post.source diff --git a/app/models/post.rb b/app/models/post.rb index 031994044..133a3b0e8 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -728,7 +728,9 @@ class Post < ActiveRecord::Base def fast_count_search(tags) 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 if count > 0 set_count_in_cache(tags, count)