add tag info to newrelic timeout errors
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
class RelatedTagCalculator
|
class RelatedTagCalculator
|
||||||
def self.find_tags(tag, limit)
|
def self.find_tags(tag, limit)
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
Post.with_timeout(5_000, []) do
|
Post.with_timeout(5_000, [], {:tags => tag}) do
|
||||||
Post.tag_match(tag).limit(limit).reorder("posts.md5").pluck(:tag_string)
|
Post.tag_match(tag).limit(limit).reorder("posts.md5").pluck(:tag_string)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -40,7 +40,7 @@ class RelatedTagCalculator
|
|||||||
counts = Hash.new {|h, k| h[k] = 0}
|
counts = Hash.new {|h, k| h[k] = 0}
|
||||||
|
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
Post.with_timeout(5_000, []) do
|
Post.with_timeout(5_000, [], {:tags => tag}) do
|
||||||
Post.tag_match(tag).limit(400).reorder("posts.md5").pluck(:tag_string).each do |tag_string|
|
Post.tag_match(tag).limit(400).reorder("posts.md5").pluck(:tag_string).each do |tag_string|
|
||||||
tag_string.scan(/\S+/).each do |tag|
|
tag_string.scan(/\S+/).each do |tag|
|
||||||
counts[tag] += 1
|
counts[tag] += 1
|
||||||
@@ -53,7 +53,7 @@ class RelatedTagCalculator
|
|||||||
candidates = convert_hash_to_array(counts, 100)
|
candidates = convert_hash_to_array(counts, 100)
|
||||||
similar_counts = Hash.new {|h, k| h[k] = 0}
|
similar_counts = Hash.new {|h, k| h[k] = 0}
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
PostReadOnly.with_timeout(5_000) do
|
PostReadOnly.with_timeout(5_000, nil, {:tags => tag}) do
|
||||||
candidates.each do |ctag, _|
|
candidates.each do |ctag, _|
|
||||||
acount = PostReadOnly.tag_match("#{tag} #{ctag}").count
|
acount = PostReadOnly.tag_match("#{tag} #{ctag}").count
|
||||||
ctag_record = Tag.find_by_name(ctag)
|
ctag_record = Tag.find_by_name(ctag)
|
||||||
|
|||||||
@@ -1061,7 +1061,7 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fast_count_search(tags, options = {})
|
def fast_count_search(tags, options = {})
|
||||||
count = PostReadOnly.with_timeout(3_000, nil) do
|
count = PostReadOnly.with_timeout(3_000, nil, {:tags => tags}) do
|
||||||
PostReadOnly.tag_match(tags).count
|
PostReadOnly.tag_match(tags).count
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1083,7 +1083,7 @@ class Post < ActiveRecord::Base
|
|||||||
i = Post.maximum(:id)
|
i = Post.maximum(:id)
|
||||||
sum = 0
|
sum = 0
|
||||||
while i > 0
|
while i > 0
|
||||||
count = PostReadOnly.with_timeout(1_000, nil) do
|
count = PostReadOnly.with_timeout(1_000, nil, {:tags => tags}) do
|
||||||
sum += PostReadOnly.tag_match(tags).where("id <= ? and id > ?", i, i - 25_000).count
|
sum += PostReadOnly.tag_match(tags).where("id <= ? and id > ?", i, i - 25_000).count
|
||||||
i -= 25_000
|
i -= 25_000
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_category_post_counts
|
def update_category_post_counts
|
||||||
Post.with_timeout(30_000, nil) do
|
Post.with_timeout(30_000, nil, {:tags => name}) do
|
||||||
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
||||||
post.reload
|
post.reload
|
||||||
post.set_tag_counts
|
post.set_tag_counts
|
||||||
|
|||||||
Reference in New Issue
Block a user