Commit 0e46ea02 by chenweitao

Merge branch 'working' into 'master'

评论量讨论量数据类型超限

See merge request !84
parents d56524dd afd2d340
...@@ -14,6 +14,8 @@ import org.bson.Document; ...@@ -14,6 +14,8 @@ import org.bson.Document;
import java.util.*; import java.util.*;
import static java.util.Objects.nonNull;
/** /**
* 热搜基础结果表 * 热搜基础结果表
*/ */
...@@ -98,20 +100,20 @@ public class HotSearchCacheDAO { ...@@ -98,20 +100,20 @@ public class HotSearchCacheDAO {
Document query = new Document("_id", id); Document query = new Document("_id", id);
//判断是否为微博推荐位,推荐位微博无排名,所以不纳入总的缓存表 //判断是否为微博推荐位,推荐位微博无排名,所以不纳入总的缓存表
if(Objects.nonNull(lastRank) && lastRank >0 ){ if(nonNull(lastRank) && lastRank >0 ){
Document nowDoc = (Document) collection.find(query).first(); Document nowDoc = (Document) collection.find(query).first();
if (Objects.nonNull(nowDoc)) { if (nonNull(nowDoc)) {
Integer highestRank = nowDoc.getInteger("highestRank"); Integer highestRank = nowDoc.getInteger("highestRank");
Long highestCount = Long.valueOf(nowDoc.get("highestCount").toString()); Long highestCount = nonNull(nowDoc.get("highestCount"))?Long.valueOf(nowDoc.get("highestCount").toString()):null;
Integer preRank = nowDoc.getInteger("lastRank"); Integer preRank = nowDoc.getInteger("lastRank");
Long preCount = Long.valueOf(nowDoc.get("lastCount").toString()); Long preCount = nonNull(nowDoc.get("lastCount"))?Long.valueOf(nowDoc.get("lastCount").toString()):null;
String lastUrl = nowDoc.getString("url"); String lastUrl = nowDoc.getString("url");
//判断最大热度值 //判断最大热度值
if (Objects.nonNull(lastCount) && Objects.nonNull(highestCount) && lastCount > highestCount) { if (nonNull(lastCount) && nonNull(highestCount) && lastCount > highestCount) {
highestCount = lastCount; highestCount = lastCount;
} }
//判断最高排名 //判断最高排名
if (Objects.nonNull(lastRank) && highestRank<0){ if (nonNull(lastRank) && highestRank<0){
highestRank = lastRank; highestRank = lastRank;
} }
if (lastRank>0 && highestRank>0 && lastRank < highestRank) { if (lastRank>0 && highestRank>0 && lastRank < highestRank) {
...@@ -122,7 +124,7 @@ public class HotSearchCacheDAO { ...@@ -122,7 +124,7 @@ public class HotSearchCacheDAO {
int durationNow = getDuration(type, duration); int durationNow = getDuration(type, duration);
//计算上升速度 //计算上升速度
double riseSpeed = nowDoc.containsKey("riseSpeed")?nowDoc.getDouble("riseSpeed"):0.00; double riseSpeed = nowDoc.containsKey("riseSpeed")?nowDoc.getDouble("riseSpeed"):0.00;
if(Objects.nonNull(lastCount) && nowDoc.containsKey("firstCount")) { if(nonNull(lastCount) && nowDoc.containsKey("firstCount")) {
long firstCount = nowDoc.getLong("firstCount"); long firstCount = nowDoc.getLong("firstCount");
riseSpeed = ((double)(lastCount - firstCount)/(double)firstCount)*1000/((double)duration); riseSpeed = ((double)(lastCount - firstCount)/(double)firstCount)*1000/((double)duration);
} }
...@@ -191,8 +193,8 @@ public class HotSearchCacheDAO { ...@@ -191,8 +193,8 @@ public class HotSearchCacheDAO {
nowDoc.put("topicLead", nowDoc.getString("topicLead")); nowDoc.put("topicLead", nowDoc.getString("topicLead"));
} }
if(nowDoc.containsKey("readCount") && nowDoc.containsKey("discussCount")) { if(nowDoc.containsKey("readCount") && nowDoc.containsKey("discussCount")) {
nowDoc.put("readCount", Long.valueOf(nowDoc.get("readCount").toString())); nowDoc.put("readCount", nonNull(nowDoc.get("readCount"))?Long.valueOf(nowDoc.get("readCount").toString()):null);
nowDoc.put("discussCount", Long.valueOf(nowDoc.get("discussCount").toString())); nowDoc.put("discussCount", nonNull(nowDoc.get("discussCount"))?Long.valueOf(nowDoc.get("discussCount").toString()):null);
} }
if (nowDoc.containsKey("pictureUrl")) { if (nowDoc.containsKey("pictureUrl")) {
nowDoc.put("pictureUrl",nowDoc.getString("pictureUrl")); nowDoc.put("pictureUrl",nowDoc.getString("pictureUrl"));
...@@ -217,7 +219,7 @@ public class HotSearchCacheDAO { ...@@ -217,7 +219,7 @@ public class HotSearchCacheDAO {
String id = (String) document.get("id"); String id = (String) document.get("id");
Document query = new Document("_id", id); Document query = new Document("_id", id);
Document nowDoc = (Document) collection.find(query).first(); Document nowDoc = (Document) collection.find(query).first();
if (Objects.nonNull(nowDoc)) { if (nonNull(nowDoc)) {
nowDoc.put("url",document.get("url")); nowDoc.put("url",document.get("url"));
collection.replaceOne(query, nowDoc); collection.replaceOne(query, nowDoc);
} }
...@@ -332,7 +334,7 @@ public class HotSearchCacheDAO { ...@@ -332,7 +334,7 @@ public class HotSearchCacheDAO {
public void updateWeibo(Document document,String id){ public void updateWeibo(Document document,String id){
Document query = new Document("_id", id); Document query = new Document("_id", id);
Document nowDoc = (Document) collection.find(query).first(); Document nowDoc = (Document) collection.find(query).first();
if (Objects.nonNull(nowDoc)) { if (nonNull(nowDoc)) {
if(Objects.isNull(nowDoc.get("topicLead"))) { if(Objects.isNull(nowDoc.get("topicLead"))) {
if (document.containsKey("topicLead") && document.getString("topicLead") != null) { if (document.containsKey("topicLead") && document.getString("topicLead") != null) {
nowDoc.put("topicLead", document.getString("topicLead")); nowDoc.put("topicLead", document.getString("topicLead"));
......
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