FIX: update_counters wasn't properly updating topic counters

This commit is contained in:
Régis Hanol
2014-07-28 22:08:31 +02:00
parent 380411457a
commit 57fef6864d
2 changed files with 14 additions and 1 deletions

View File

@@ -331,7 +331,8 @@ class PostAction < ActiveRecord::Base
end
topic_id = Post.with_deleted.where(id: post_id).pluck(:topic_id).first
Topic.where(id: topic_id).update_all ["#{column} = ?", count]
topic_count = Post.where(topic_id: topic_id).sum(column)
Topic.where(id: topic_id).update_all ["#{column} = ?", topic_count]
if PostActionType.notify_flag_type_ids.include?(post_action_type_id)
PostAction.update_flagged_posts_count