|
|
|
@ -3065,7 +3065,7 @@ def host_with_protocol
|
|
|
|
|
return Setting.protocol + "://" + Setting.host_name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#将有置顶属性的提到数组前面 #infocount 相同的按时间降序排列
|
|
|
|
|
#将有置顶属性的提到数组前面
|
|
|
|
|
def sort_by_sticky topics
|
|
|
|
|
tmpTopics = []
|
|
|
|
|
tmpIndex = 0
|
|
|
|
@ -3082,8 +3082,116 @@ def sort_by_sticky topics
|
|
|
|
|
tmpIndex = tmpIndex + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return tmpTopics
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#按人气排序的时候 相同的人气必须按某种时间顺序排序 有置顶属性
|
|
|
|
|
def sortby_time_countcommon_hassticky topics,sortstr
|
|
|
|
|
tmpTopics = []
|
|
|
|
|
tmpTopics = topics
|
|
|
|
|
tStart = -1
|
|
|
|
|
tEnd = -1
|
|
|
|
|
|
|
|
|
|
tmpTopics_1 = []
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
|
|
|
|
|
tmpTopics.each_with_index do |topic,index|
|
|
|
|
|
if topic.sticky == 0
|
|
|
|
|
if tStart == -1
|
|
|
|
|
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
|
|
|
|
|
tStart = index
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
|
|
|
|
|
tEnd = index
|
|
|
|
|
else
|
|
|
|
|
if (topic[:infocount] == tmpTopics[index-1][:infocount])
|
|
|
|
|
tEnd = index
|
|
|
|
|
end
|
|
|
|
|
if tEnd > tStart
|
|
|
|
|
for i in tStart..tEnd
|
|
|
|
|
tmpTopics_1[tmpIndex] = tmpTopics[i]
|
|
|
|
|
tmpIndex = tmpIndex + 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if sortstr == "created_at"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
|
|
|
|
|
elsif sortstr == "created_on"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
|
|
|
|
|
elsif sortstr == "updated_at"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
|
|
|
|
|
elsif sortstr == "updated_on"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
for i in tStart..tEnd
|
|
|
|
|
tmpTopics[i] = tmpTopics_1[tmpIndex]
|
|
|
|
|
tmpIndex = tmpIndex + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
tStart = -1
|
|
|
|
|
tEnd = -1
|
|
|
|
|
tmpTopics_1 = []
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return tmpTopics
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#按人气排序的时候 相同的人气必须按某种时间顺序排序 无置顶属性
|
|
|
|
|
def sortby_time_countcommon_nosticky topics,sortstr
|
|
|
|
|
tmpTopics = []
|
|
|
|
|
tmpTopics = topics
|
|
|
|
|
tStart = -1
|
|
|
|
|
tEnd = -1
|
|
|
|
|
|
|
|
|
|
tmpTopics_1 = []
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
|
|
|
|
|
topics = tmpTopics
|
|
|
|
|
return topics
|
|
|
|
|
tmpTopics.each_with_index do |topic,index|
|
|
|
|
|
if tStart == -1
|
|
|
|
|
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
|
|
|
|
|
tStart = index
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
|
|
|
|
|
tEnd = index
|
|
|
|
|
else
|
|
|
|
|
if (topic[:infocount] == tmpTopics[index-1][:infocount])
|
|
|
|
|
tEnd = index
|
|
|
|
|
end
|
|
|
|
|
if tEnd > tStart
|
|
|
|
|
for i in tStart..tEnd
|
|
|
|
|
tmpTopics_1[tmpIndex] = tmpTopics[i]
|
|
|
|
|
tmpIndex = tmpIndex + 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if sortstr == "created_at"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
|
|
|
|
|
elsif sortstr == "created_on"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
|
|
|
|
|
elsif sortstr == "updated_at"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
|
|
|
|
|
elsif sortstr == "updated_on"
|
|
|
|
|
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
for i in tStart..tEnd
|
|
|
|
|
tmpTopics[i] = tmpTopics_1[tmpIndex]
|
|
|
|
|
tmpIndex = tmpIndex + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
tStart = -1
|
|
|
|
|
tEnd = -1
|
|
|
|
|
tmpTopics_1 = []
|
|
|
|
|
tmpIndex = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return tmpTopics
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|