From fff581dc28baf4c86736ee7b25fef81f3d899590 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 18 Mar 2013 09:28:31 -0700 Subject: [PATCH] no longer decrement post counts when post is deleted --- app/logical/tag_correction.rb | 2 +- app/models/post.rb | 3 ++- script/fixes/007.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/logical/tag_correction.rb b/app/logical/tag_correction.rb index cfbc4746d..834f625d6 100644 --- a/app/logical/tag_correction.rb +++ b/app/logical/tag_correction.rb @@ -44,6 +44,6 @@ class TagCorrection def fix! tag.delay(:queue => "default").fix_post_count - Post.expire_cache_for_all(tag.name) + Post.expire_cache_for_all([tag.name]) end end diff --git a/app/models/post.rb b/app/models/post.rb index 5c94c3c70..712139b7e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -762,6 +762,7 @@ class Post < ActiveRecord::Base end ModAction.create(:description => "permanently deleted post ##{id}") + decrement_tag_post_counts delete!(:without_mod_action => true) destroy end @@ -779,7 +780,7 @@ class Post < ActiveRecord::Base give_favorites_to_parent update_children_on_destroy update_parent_on_destroy - decrement_tag_post_counts + # decrement_tag_post_counts update_column(:parent_id, nil) Post.expire_cache_for_all(tag_array) diff --git a/script/fixes/007.rb b/script/fixes/007.rb index 0c36bb6a0..0ca00187b 100644 --- a/script/fixes/007.rb +++ b/script/fixes/007.rb @@ -3,5 +3,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) ActiveRecord::Base.connection.execute("set statement_timeout = 0") -ActiveRecord::Base.connection.execute("update comments set updater_id = creator_id") +ActiveRecord::Base.connection.execute("update comments set updater_id = creator_id where updater_id is null") ActiveRecord::Base.connection.execute("update tags set post_count = 0 where post_count < 0")