addresses #2171: daily maintenance task to clean up negative post count tags

This commit is contained in:
r888888888
2015-08-07 15:33:13 -07:00
parent a9502c0dc2
commit 41e3d7f057
2 changed files with 7 additions and 0 deletions

View File

@@ -15,5 +15,6 @@ class DailyMaintenance
ForumSubscription.process_all!
TagAlias.update_cached_post_counts_for_all
PostDisapproval.dmail_messages!
Tag.clean_up_negative_post_counts!
end
end

View File

@@ -57,6 +57,12 @@ class Tag < ActiveRecord::Base
Tag.where(:name => tag_names).update_all("post_count = post_count - 1")
Post.expire_cache_for_all(tag_names)
end
def clean_up_negative_post_counts!
Tag.where("post_count < 0").find_each do |tag|
tag.fix_post_count
end
end
end
def real_post_count