Commit 68042147 authored by 刘基明's avatar 刘基明

排序优化

parent 38d2c969
......@@ -154,11 +154,14 @@ public class RankService {
return;
}
List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToHotQos(topicEntities);
// 统计话题下的所有主题数据
List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList());
Map<String, Integer> topicViewMap = visitLogService.getCountMapByTargetIds(topicIds, PageEnum.COMM_VISIT_TOPIC_DETAIL.getId());
for (TopicRankQo topic : topicRankQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
if (CollectionUtils.isEmpty(themeIds)) {
topic.setViewCount(topicViewMap.getOrDefault(topic.getTopicId(), 0));
topic.setDisscussCount(0);
topic.setThemeWeight(0.0);
......@@ -183,6 +186,10 @@ public class RankService {
topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount()));
}
// 记录排序前最新的2个话题
List<TopicRankQo> newest2Topic = topicRankQos.stream().filter(TopicRankQo::judgeNewTopic).limit(2).collect(Collectors.toList());
// 排序
List<TopicRankQo> rankList = topicRankQos.stream()
.sorted(Comparator.comparing(TopicRankQo::getScore).reversed())
......@@ -194,7 +201,7 @@ public class RankService {
this.rankTopicList = rankList;
// 首页推荐话题
List<TopicRankQo> newest2Topic = rankList.stream().filter(TopicRankQo::judgeNewTopic).limit(2).collect(Collectors.toList());
List<TopicRankQo> top4Topic = rankList.stream()
.limit(6)
.filter(o -> !newest2Topic.contains(o))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment