From 10b2523ac33ee5a81009fec9e0fc726ccccf3594 Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 7 Aug 2015 20:15:13 -0400 Subject: [PATCH] #2171: Also clean up inflated post counts --- app/models/tag.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/tag.rb b/app/models/tag.rb index 8705ac511..41522da38 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -60,7 +60,11 @@ class Tag < ActiveRecord::Base def clean_up_negative_post_counts! Tag.where("post_count < 0").find_each do |tag| + tag_alias = TagAlias.where("status in ('active', 'processing') and antecedent_name = ?", tag.name).first tag.fix_post_count + if tag_alias + tag_alias.consequent_tag.fix_post_count + end end end end