Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
searchhotcrawler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhiwei
searchhotcrawler
Commits
0e46ea02
Commit
0e46ea02
authored
May 27, 2021
by
chenweitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'working' into 'master'
评论量讨论量数据类型超限 See merge request
!84
parents
d56524dd
afd2d340
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
+13
-11
No files found.
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
View file @
0e46ea02
...
@@ -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"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment