Merge pull request #2992 from evazion/fix-calc-reltags-from-posts

Fix slow related tag calculations when searching single metatags.
This commit is contained in:
Albert Yi
2017-04-24 14:13:41 -07:00
committed by GitHub
3 changed files with 13 additions and 19 deletions

View File

@@ -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