列表修改
This commit is contained in:
parent
789f3906a5
commit
f8abd46ae9
|
@ -24,7 +24,12 @@ class BlogsController < ApplicationController
|
|||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
|
||||
|
||||
@topics.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
|
||||
end
|
||||
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
|
||||
@topics = sort_by_sticky @topics
|
||||
else
|
||||
|
|
|
@ -124,7 +124,10 @@ class BoardsController < ApplicationController
|
|||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
|
||||
@topics.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + (topic.parent ? x.parent.children.count : topic.children.count)
|
||||
end
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
@topics = sort_by_sticky @topics
|
||||
else
|
||||
@type = 1
|
||||
|
|
|
@ -104,7 +104,10 @@ class NewsController < ApplicationController
|
|||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| get_praise_num(x) + x.comments.count <=> get_praise_num(y) + y.comments.count } : scope_order = scope_order.sort{|x,y| get_praise_num(y) + y.comments.count <=> get_praise_num(x) + x.comments.count }
|
||||
scope_order.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + topic.comments.count
|
||||
end
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
scope_order = sort_by_sticky scope_order
|
||||
else
|
||||
@type = 1
|
||||
|
|
|
@ -2913,7 +2913,11 @@ class UsersController < ApplicationController
|
|||
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@c_sort == 1 ? (@projects = @projects.sort{|x,y| x.project_score.issue_num+x.project_score.attach_num <=> y.project_score.issue_num+y.project_score.attach_num }) : (@projects = @projects.sort{|x,y| y.project_score.issue_num+y.project_score.attach_num <=> x.project_score.issue_num+x.project_score.attach_num })
|
||||
@projects.each do |project|
|
||||
project[:infocount] = project.project_score.issue_num+project.project_score.attach_num
|
||||
end
|
||||
|
||||
@c_sort == 1 ? (@projects = @projects.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@projects = @projects.sort{|x,y| y[:infocount] <=> x[:infocount] })
|
||||
else
|
||||
@type = 1
|
||||
end
|
||||
|
|
|
@ -3065,7 +3065,7 @@ def host_with_protocol
|
|||
return Setting.protocol + "://" + Setting.host_name
|
||||
end
|
||||
|
||||
#将有置顶属性的提到数组前面
|
||||
#将有置顶属性的提到数组前面 #infocount 相同的按时间降序排列
|
||||
def sort_by_sticky topics
|
||||
tmpTopics = []
|
||||
tmpIndex = 0
|
||||
|
@ -3084,7 +3084,6 @@ def sort_by_sticky topics
|
|||
end
|
||||
|
||||
topics = tmpTopics
|
||||
|
||||
return topics
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue