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

@@ -15,7 +15,7 @@ module DanbooruMaintenance
ForumSubscription.process_all!
TagAlias.update_cached_post_counts_for_all
PostDisapproval.dmail_messages!
Tag.clean_up_negative_post_counts!
regenerate_post_counts!
SuperVoter.init!
TokenBucket.prune!
TagChangeRequestPruner.warn_all
@@ -38,6 +38,13 @@ module DanbooruMaintenance
rescue_exception(exception)
end
def regenerate_post_counts!
updated_tags = Tag.regenerate_post_counts!
updated_tags.each do |tag|
DanbooruLogger.info("Updated tag count", tag.attributes)
end
end
def rescue_exception(exception)
DanbooruLogger.log(exception)
raise exception

View File

@@ -4,14 +4,14 @@ class TagCorrection
include ActiveModel::Serializers::Xml
attr_reader :tag
delegate :category, :post_count, :real_post_count, to: :tag
delegate :category, :post_count, to: :tag
def initialize(tag_id)
@tag = Tag.find(tag_id)
end
def attributes
{ post_count: post_count, real_post_count: real_post_count, category: category, category_cache: category_cache, tag: tag }
{ post_count: post_count, category: category, category_cache: category_cache, tag: tag }
end
def category_cache
@@ -19,7 +19,6 @@ class TagCorrection
end
def fix!
FixTagPostCountJob.perform_later(tag)
tag.update_category_cache
end
end