summaryrefslogtreecommitdiffstats
path: root/app/models/board.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-22 18:51:00 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-22 18:51:00 +0000
commit360895068e3d81bfc7bf34b85b3b0c1fe0a6be60 (patch)
tree88b60f91d8f607376f659d048e21192a109d9da4 /app/models/board.rb
parent498a34403ad3f15dee2067e9d8998675255010ce (diff)
downloadredmine-360895068e3d81bfc7bf34b85b3b0c1fe0a6be60.tar.gz
redmine-360895068e3d81bfc7bf34b85b3b0c1fe0a6be60.zip
Code cleanup, use array instead of handcrafted update.
git-svn-id: http://svn.redmine.org/redmine/trunk@13485 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/board.rb')
-rw-r--r--app/models/board.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/board.rb b/app/models/board.rb
index 4a9984a03..9777771a5 100644
--- a/app/models/board.rb
+++ b/app/models/board.rb
@@ -63,10 +63,10 @@ class Board < ActiveRecord::Base
# Updates topics_count, messages_count and last_message_id attributes for +board_id+
def self.reset_counters!(board_id)
board_id = board_id.to_i
- where(["id = ?", board_id]).
- update_all("topics_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=#{board_id} AND parent_id IS NULL)," +
- " messages_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=#{board_id})," +
- " last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})")
+ Board.where(:id => board_id).
+ update_all(["topics_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=:id AND parent_id IS NULL)," +
+ " messages_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=:id)," +
+ " last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=:id)", :id => board_id])
end
def self.board_tree(boards, parent_id=nil, level=0)