主题帖子数量不算在回复数之中

This commit is contained in:
yanxd 2013-11-28 15:51:38 +08:00
parent 8f707f3987
commit cc9dca4012
1 changed files with 1 additions and 1 deletions

View File

@ -25,7 +25,7 @@ class Forum < ActiveRecord::Base
def self.reset_counters!(forum_id)
forum_id = forum_id.to_i
update_all("topic_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id} AND parent_id IS NULL)," +
" memo_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id})," +
" memo_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id} AND parent_id IS NOT NULL)," +
" last_memo_id = (SELECT MAX(id) FROM #{Memo.table_name} WHERE forum_id=#{forum_id})",
["id = ?", forum_id])
end