add sanity check for update category post counts method

This commit is contained in:
albert
2013-03-10 00:35:36 -05:00
parent 27926df522
commit f96cd644bc
3 changed files with 7 additions and 5 deletions

View File

@@ -98,8 +98,10 @@ class Tag < ActiveRecord::Base
def update_category_post_counts
old_field = "tag_count_#{Danbooru.config.reverse_tag_category_mapping[category_was]}".downcase
new_field = "tag_count_#{category_name}".downcase
Post.without_timeout do
Post.raw_tag_match(name).update_all("#{old_field} = #{old_field} - 1, #{new_field} = #{new_field} + 1")
if old_field != new_field
Post.without_timeout do
Post.raw_tag_match(name).update_all("#{old_field} = #{old_field} - 1, #{new_field} = #{new_field} + 1")
end
end
end