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
64bf0be4
Commit
64bf0be4
authored
May 20, 2020
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复计算热搜时间错误的问题
parent
931e03e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
+38
-2
No files found.
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
View file @
64bf0be4
...
...
@@ -63,7 +63,7 @@ public class HotSearchCacheDAO {
int
lastRank
=
document
.
getInteger
(
"rank"
)!=
null
?
document
.
getInteger
(
"rank"
):
-
1
;
int
lastCount
=
document
.
getInteger
(
"count"
)!=
null
?
document
.
getInteger
(
"count"
):
-
1
;
Date
startTime
=
document
.
getDate
(
"time"
);
Date
endTime
=
new
Date
(
startTime
.
getTime
()
+
(
60
*
1000
)
);
Date
endTime
=
getEndTime
(
type
,
startTime
);
String
topicLead
=
document
.
getString
(
"topic_lead"
)!=
null
?
document
.
getString
(
"topic_lead"
):
null
;
boolean
hot
=
document
.
getBoolean
(
"hot"
)!=
null
?
document
.
getBoolean
(
"hot"
):
true
;
String
url
=
document
.
getString
(
"url"
)!=
null
?
document
.
getString
(
"url"
):
null
;
...
...
@@ -85,7 +85,7 @@ public class HotSearchCacheDAO {
//计算热搜时长
int
duration
=
nowDoc
.
getInteger
(
"duration"
);
int
durationNow
=
getDuration
(
type
,
duration
);
endTime
=
new
Date
(
System
.
currentTimeMillis
()
+
(
60
*
1000
));
endTime
=
getEndTime
(
type
,
new
Date
(
));
//更新相应信息
nowDoc
.
put
(
"endTime"
,
endTime
);
nowDoc
.
put
(
"lastRank"
,
lastRank
);
...
...
@@ -155,6 +155,42 @@ public class HotSearchCacheDAO {
}
/**
* 计算结束时间
* @param type
* @param time
* @return
*/
private
Date
getEndTime
(
String
type
,
Date
time
){
long
timeLong
=
time
.
getTime
();
switch
(
type
){
case
"微博热搜"
:
timeLong
=
timeLong
+
1
*
60
*
1000
;
break
;
case
"百度热搜"
:
timeLong
=
timeLong
+
5
*
60
*
1000
;
break
;
case
"知乎热搜"
:
timeLong
=
timeLong
+
10
*
60
*
1000
;
break
;
case
"抖音热搜"
:
timeLong
=
timeLong
+
10
*
60
*
1000
;
break
;
case
"搜狗微信热搜"
:
timeLong
=
timeLong
+
5
*
60
*
1000
;
break
;
case
"微博话题"
:
timeLong
=
timeLong
+
3
*
60
*
1000
;
break
;
case
"今日头条热搜"
:
timeLong
=
timeLong
+
1
*
60
*
1000
;
break
;
default
:
timeLong
=
timeLong
+
1
*
60
*
1000
;
}
return
new
Date
(
timeLong
);
}
}
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