update to rails 4.2.5.1, add debugging info for tracking slow queries
This commit is contained in:
@@ -12,7 +12,7 @@ module Moderator
|
||||
|
||||
CurrentUser.without_safe_mode do
|
||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||
::Post.tag_match(antecedent).find_each do |post|
|
||||
::Post.tag_match(antecedent).where("true /* Moderator::TagBatchChange#perform */").find_each do |post|
|
||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||
post.update_attributes(:tag_string => tags)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module PostSets
|
||||
|
||||
def posts
|
||||
@posts ||= begin
|
||||
query = ::Post.tag_match(@artist.name).limit(10)
|
||||
query = ::Post.tag_match(@artist.name).where("true /* PostSets::Artist#posts */").limit(10)
|
||||
query.each # hack to force rails to eager load
|
||||
query
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def has_deleted?
|
||||
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
||||
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").where("true /* PostSets::Post#has_deleted */").exists?
|
||||
end
|
||||
|
||||
def has_explicit?
|
||||
@@ -127,9 +127,9 @@ module PostSets
|
||||
if random
|
||||
temp = get_random_posts()
|
||||
elsif raw
|
||||
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").paginate(page, :count => post_count, :limit => per_page)
|
||||
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").where("true /* PostSets::Post#posts:1 */").paginate(page, :count => post_count, :limit => per_page)
|
||||
else
|
||||
temp = ::Post.tag_match(tag_string, read_only).paginate(page, :count => post_count, :limit => per_page)
|
||||
temp = ::Post.tag_match(tag_string, read_only).where("true /* PostSets::Post#posts:2 */").paginate(page, :count => post_count, :limit => per_page)
|
||||
end
|
||||
temp.each # hack to force rails to eager load
|
||||
temp
|
||||
|
||||
@@ -53,9 +53,9 @@ class RelatedTagCalculator
|
||||
candidates = convert_hash_to_array(counts, 100)
|
||||
similar_counts = Hash.new {|h, k| h[k] = 0}
|
||||
CurrentUser.without_safe_mode do
|
||||
Post.with_timeout(5_000) do
|
||||
PostReadOnly.with_timeout(5_000) do
|
||||
candidates.each do |ctag, _|
|
||||
acount = Post.tag_match("#{tag} #{ctag}").count
|
||||
acount = PostReadOnly.tag_match("#{tag} #{ctag}").count
|
||||
ctag_record = Tag.find_by_name(ctag)
|
||||
div = Math.sqrt(tag_record.post_count * ctag_record.post_count)
|
||||
if div != 0
|
||||
|
||||
@@ -6,7 +6,7 @@ class UserDeletion
|
||||
def self.remove_favorites_for(user_id)
|
||||
user = User.find(user_id)
|
||||
Post.without_timeout do
|
||||
Post.raw_tag_match("fav:#{user_id}").find_each do |post|
|
||||
Post.raw_tag_match("fav:#{user_id}").where("true /* UserDeletion.remove_favorites_for */").find_each do |post|
|
||||
Favorite.remove(post, user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -183,7 +183,7 @@ class Artist < ActiveRecord::Base
|
||||
if params[:name]
|
||||
artist.name = params[:name]
|
||||
post = CurrentUser.without_safe_mode do
|
||||
Post.tag_match("source:http #{artist.name}").first
|
||||
Post.tag_match("source:http #{artist.name}").where("true /* Artist.new_with_defaults */").first
|
||||
end
|
||||
unless post.nil? || post.source.blank?
|
||||
artist.url_string = post.source
|
||||
@@ -271,7 +271,7 @@ class Artist < ActiveRecord::Base
|
||||
ti.destroy if ti
|
||||
|
||||
begin
|
||||
Post.tag_match(name).each do |post|
|
||||
Post.tag_match(name).where("true /* Artist.unban */").each do |post|
|
||||
post.unban!
|
||||
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
||||
post.update_attributes(:tag_string => fixed_tags)
|
||||
@@ -289,7 +289,7 @@ class Artist < ActiveRecord::Base
|
||||
Post.transaction do
|
||||
CurrentUser.without_safe_mode do
|
||||
begin
|
||||
Post.tag_match(name).each do |post|
|
||||
Post.tag_match(name).where("true /* Artist.ban */").each do |post|
|
||||
post.ban!
|
||||
end
|
||||
rescue Post::SearchError
|
||||
|
||||
@@ -71,7 +71,7 @@ class Tag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def real_post_count
|
||||
@real_post_count ||= Post.raw_tag_match(name).count
|
||||
@real_post_count ||= Post.raw_tag_match(name).where("true /* Tag#real_post_count */").count
|
||||
end
|
||||
|
||||
def fix_post_count
|
||||
@@ -131,7 +131,7 @@ class Tag < ActiveRecord::Base
|
||||
|
||||
def update_category_post_counts
|
||||
Post.with_timeout(30_000, nil) do
|
||||
Post.raw_tag_match(name).find_each do |post|
|
||||
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)
|
||||
|
||||
@@ -186,7 +186,7 @@ class TagImplication < ActiveRecord::Base
|
||||
|
||||
def update_posts
|
||||
Post.without_timeout do
|
||||
Post.raw_tag_match(antecedent_name).find_each do |post|
|
||||
Post.raw_tag_match(antecedent_name).where("true /* TagImplication#update_posts */").find_each do |post|
|
||||
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
|
||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||
post.update_attributes(
|
||||
|
||||
Reference in New Issue
Block a user