tags: automatically fix incorrect tag counts during maintenance.

* Automatically fix all tags with incorrect counts during daily
  maintenance (previously only tags with negative counts were fixed).
* Log fixed tags to NewRelic.
* Remove the ability to manually fix tag counts with the "Fix" button on
  the /tags listing. This is no longer necessary now that tags are
  fixed automatically.
This commit is contained in:
evazion
2019-09-25 17:33:15 -05:00
parent 03d9b3feca
commit bc34fb16a4
12 changed files with 36 additions and 89 deletions

View File

@@ -274,13 +274,15 @@ class TagTest < ActiveSupport::TestCase
end
end
context "A tag with a negative post count" do
context "A tag with an incorrect post count" do
should "be fixed" do
tag = FactoryBot.create(:tag, name: "touhou", post_count: -10)
post = FactoryBot.create(:post, tag_string: "touhou")
tag1 = FactoryBot.create(:tag, name: "touhou", post_count: -10)
tag2 = FactoryBot.create(:tag, name: "bkub", post_count: 10)
post = FactoryBot.create(:post, tag_string: "touhou bkub")
Tag.clean_up_negative_post_counts!
assert_equal(1, tag.reload.post_count)
Tag.regenerate_post_counts!
assert_equal(1, tag1.reload.post_count)
assert_equal(1, tag2.reload.post_count)
end
end
end