related_tag_calculator.rb: fix memcache lookup in inner loop.
Remove the category constraint option from RelatedTagCalculator.calculate_from_posts. It slows things down and isn't used. This method is used to calculate the related tags sidebar during searches for single metatags. Using Tag.category_for in the inner loop caused a memcache call on every iteration. At 100 posts per page and 20-30 tags per post, this led to up to 2000-3000 total memcache calls, which significantly slowed pageloads.
This commit is contained in:
@@ -18,11 +18,11 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase
|
||||
FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd")
|
||||
FactoryGirl.create(:post, :tag_string => "aaa bbb ccc")
|
||||
FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||
@post_set = PostSets::Post.new("aaa")
|
||||
@posts = Post.tag_match("aaa")
|
||||
end
|
||||
|
||||
should "calculate the related tags" do
|
||||
assert_equal({"aaa"=>3, "bbb"=>3, "ccc"=>2, "ddd"=>1}, RelatedTagCalculator.calculate_from_post_set(@post_set))
|
||||
assert_equal({"aaa"=>3, "bbb"=>3, "ccc"=>2, "ddd"=>1}, RelatedTagCalculator.calculate_from_posts(@posts))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user