Commit a0333434 by zhiwei

修复计算热搜排名由于历史数据错误导致的当前数据错误问题,并添加上一次的排名及热度功能

parent 64bf0be4
......@@ -68,7 +68,6 @@ public class HotSearchCacheDAO {
boolean hot = document.getBoolean("hot")!=null?document.getBoolean("hot"):true;
String url = document.getString("url")!=null?document.getString("url"):null;
String id = name + "_" + type;
Document query = new Document("_id", id);
Document nowDoc = (Document) collection.find(query).first();
if (Objects.nonNull(nowDoc)) {
......@@ -79,6 +78,9 @@ public class HotSearchCacheDAO {
highestCount = lastCount;
}
//判断最高排名
if (highestRank<0){
highestRank = lastRank;
}
if (lastRank>0 && highestRank>0 && lastRank < highestRank) {
highestRank = lastRank;
}
......@@ -92,6 +94,8 @@ public class HotSearchCacheDAO {
nowDoc.put("lastCount", lastCount);
nowDoc.put("highestRank", highestRank);
nowDoc.put("highestCount", highestCount);
nowDoc.put("preRank", null);
nowDoc.put("preCount", null);
nowDoc.put("duration", durationNow);
collection.replaceOne(query, nowDoc);
} else {
......@@ -110,6 +114,8 @@ public class HotSearchCacheDAO {
nowDoc.put("startTime", startTime);
nowDoc.put("endTime", endTime);
nowDoc.put("duration", durationNow);
nowDoc.put("preRank", nowDoc.getInteger("lastRank"));
nowDoc.put("preCount", nowDoc.getInteger("lastCount"));
collection.insertOne(nowDoc);
}
......
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