From 0dd7ef4460b794fcd66f74f554a5e892e4015c5a Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 4 Jul 2016 14:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=95=B0=E4=B8=8E=E5=AE=9E=E9=99=85=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 4 +++- app/views/users/_course_boardlist.html.erb | 8 ++------ app/views/users/_project_boardlist.html.erb | 8 ++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 9a72bb4df..ceb63d7b0 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -125,7 +125,9 @@ class BoardsController < ApplicationController if @order.to_i == 2 @type = 2 @topics.each do |topic| - topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count) + all_comments = [] + count=get_all_children(all_comments, topic).count + topic[:infocount] = get_praise_num(topic) + count if topic[:infocount] < 0 topic[:infocount] = 0 end diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb index 5cb2c27a7..bdff80d33 100644 --- a/app/views/users/_course_boardlist.html.erb +++ b/app/views/users/_course_boardlist.html.erb @@ -46,12 +46,8 @@ 发帖人: <%=(u.try(:realname) != " " ? u.lastname + u.firstname : u.try(:login)) %> 更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %> - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %>

<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>

diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb index fe7bc03f2..3ba0244d9 100644 --- a/app/views/users/_project_boardlist.html.erb +++ b/app/views/users/_project_boardlist.html.erb @@ -46,12 +46,8 @@ 发帖人:<%=(u.try(:realname) != " " ? u.lastname + u.firstname : u.try(:login)) %> 更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %> - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %>

<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>