Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
da281864
Commit
da281864
authored
Aug 04, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热度算法优化 参数fix
parent
488a1b72
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
19 deletions
+18
-19
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+1
-3
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+4
-3
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+1
-1
application-dev.yml
community-service/src/main/resources/application-dev.yml
+12
-12
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
da281864
...
...
@@ -22,8 +22,6 @@ public class ThemeAnalysDO {
@ApiModelProperty
(
value
=
"作者id"
)
private
String
authorId
;
@ApiModelProperty
(
value
=
"被转发的主题"
)
private
String
formerThemeId
;
@ApiModelProperty
(
value
=
"所属的话题"
)
private
String
topicId
;
...
...
@@ -44,7 +42,7 @@ public class ThemeAnalysDO {
private
Integer
viewCount
;
@ApiModelProperty
(
value
=
"距今时间"
)
private
Long
minute
TillNow
;
private
Long
hours
TillNow
;
@ApiModelProperty
(
value
=
"用户质量"
)
private
Double
userWeight
=
0.0
;
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
da281864
...
...
@@ -175,12 +175,14 @@ public class RankService {
.
sum
();
topic
.
setThemeWeight
(
themeSum
);
}
// 打分
calculateTopicScore
(
topic
);
//格式化浏览量、讨论量
//
格式化浏览量、讨论量
topic
.
setFormatViewCount
(
BizUtils
.
formatCountNumber
(
topic
.
getViewCount
()));
topic
.
setFormatDisscussCount
(
BizUtils
.
formatCountNumber
(
topic
.
getDisscussCount
()));
}
// 排序
Map
<
TopicRankQo
,
Double
>
map
=
topicRankQos
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
TopicRankQo:
:
getScore
));
List
<
TopicRankQo
>
rankList
=
map
.
entrySet
().
stream
()
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()))
...
...
@@ -258,8 +260,7 @@ public class RankService {
+
theme
.
getLikeCount
()
*
likeRaten
+
theme
.
getCollectCount
()
*
collectRate
+
Math
.
pow
(
theme
.
getUserWeight
(),
userWeightRate
);
double
t
=
Double
.
valueOf
(
theme
.
getMinuteTillNow
())
/
60
;
double
score
=
(
w
+
initialWeight
)
/
Math
.
pow
(
t
+
1
,
timeRate
);
double
score
=
(
w
+
initialWeight
)
/
Math
.
pow
(
theme
.
getHoursTillNow
()
+
1
,
timeRate
);
theme
.
setScore
(
score
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
da281864
...
...
@@ -47,7 +47,7 @@ public class ConvertUtil {
}
ThemeAnalysDO
themeAnalysDO
=
new
ThemeAnalysDO
();
BeanUtils
.
copyProperties
(
themeEntity
,
themeAnalysDO
);
themeAnalysDO
.
set
MinuteTillNow
(
TimeUtils
.
calMinute
TillNow
(
themeEntity
.
getCreateTime
()));
themeAnalysDO
.
set
HoursTillNow
(
TimeUtils
.
calHours
TillNow
(
themeEntity
.
getCreateTime
()));
return
themeAnalysDO
;
}
...
...
community-service/src/main/resources/application-dev.yml
View file @
da281864
...
...
@@ -98,16 +98,16 @@ recommend:
rank
:
theme
:
viewRat
io
:
0.
1
forwardRat
io
:
3
commentRat
io
:
2
likeRat
ion
:
1
collectRat
io
:
3
userWeightRat
io
:
0.9
initialWeight
:
1.0
timeRat
ion
:
0.2
viewRat
e
:
0.1
1
forwardRat
e
:
31
commentRat
e
:
21
likeRat
en
:
1
1
collectRat
e
:
31
userWeightRat
e
:
0.91
initialWeight
:
1.0
11
timeRat
e
:
0.21
topic
:
viewRate
:
2
discussRate
:
3
themeRate
:
3
timeRate
:
1
viewRate
:
2
1
discussRate
:
3
1
themeRate
:
3
1
timeRate
:
1
1
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