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
41834a1e
Commit
41834a1e
authored
Aug 04, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化推荐系数
parent
a546391f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
16 deletions
+36
-16
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+15
-3
ConJobManager.java
.../main/java/com/tanpu/community/manager/ConJobManager.java
+8
-1
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+13
-12
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
41834a1e
...
...
@@ -50,11 +50,23 @@ public class ThemeAnalysDO {
private
Double
userWeight
=
0.0
;
public
Double
getRank
()
{
double
viewRatio
=
0.1
;
double
forwardRatio
=
3
;
double
commentRatio
=
2
;
double
likeRation
=
1
;
double
collectRatio
=
3
;
double
userWeightRatio
=
0.8
;
double
initialWeight
=
1.0
;
double
timeRation
=
0.3
;
// 质量=帖子质量+用户质量
double
w
=
(
double
)
(
viewCount
*
0.1
+
forwardCount
*
3
+
commentCount
*
2
+
likeCount
*
1
+
collectCount
*
3
)
+
userWeight
;
double
i
=
1
;
// 初始权重
double
w
=
viewCount
*
viewRatio
+
forwardCount
*
forwardRatio
+
commentCount
*
commentRatio
+
likeCount
*
likeRation
+
collectCount
*
collectRatio
+
Math
.
pow
(
userWeight
,
userWeightRatio
);
double
i
=
initialWeight
;
// 初始权重
double
t
=
Double
.
valueOf
(
minuteTillNow
)
/
60
;
double
g
=
0.1
;
// 时间系数
double
g
=
timeRation
;
// 时间系数
return
(
w
+
i
)
/
Math
.
pow
(
t
+
1
,
g
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ConJobManager.java
View file @
41834a1e
...
...
@@ -40,10 +40,17 @@ public class ConJobManager {
/**
* 定时统计主题、话题排行
*/
@Scheduled
(
cron
=
"
0 */1
* * * ?"
)
@Scheduled
(
cron
=
"
*/30 *
* * * ?"
)
public
void
themeRank
()
{
rankService
.
rankThemes
();
rankService
.
rankTopics
();
}
/**
* 定时统计主题、话题排行
*/
@Scheduled
(
cron
=
"*/5 * * * * ?"
)
public
void
getThemeNewest
()
{
recommendService
.
refreshNewestThemes
();
}
}
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
41834a1e
...
...
@@ -129,26 +129,28 @@ public class RecommendService {
int
newTimes
=
newRatio
;
int
recTimes
=
pythonRatio
;
String
id
;
while
(
hotTimes
>
0
&&
hotThemeIds
.
size
()
>
hot
Idx
)
{
id
=
hotThemeIds
.
get
(
hot
Idx
);
while
(
newTimes
>
0
&&
newThemeIds
.
size
()
>
new
Idx
)
{
id
=
newThemeIds
.
get
(
new
Idx
);
if
(!
set
.
contains
(
id
))
{
result
.
add
(
id
);
set
.
add
(
id
);
}
hot
Idx
++;
hot
Times
--;
new
Idx
++;
new
Times
--;
}
while
(
newTimes
>
0
&&
newThemeIds
.
size
()
>
newIdx
)
{
id
=
newThemeIds
.
get
(
newIdx
);
while
(
hotTimes
>
0
&&
hotThemeIds
.
size
()
>
hotIdx
)
{
id
=
hotThemeIds
.
get
(
hotIdx
);
if
(!
set
.
contains
(
id
))
{
result
.
add
(
id
);
set
.
add
(
id
);
}
new
Idx
++;
new
Times
--;
hot
Idx
++;
hot
Times
--;
}
while
(
recTimes
>
0
&&
recThemeIds
.
size
()
>
recIdx
)
{
id
=
recThemeIds
.
get
(
recIdx
);
if
(!
set
.
contains
(
id
))
{
...
...
@@ -170,15 +172,14 @@ public class RecommendService {
int
round
=
0
;
while
(
true
)
{
int
hotStart
=
round
*
6
;
int
newestStart
=
round
*
3
;
int
hotStart
=
round
*
3
;
int
newestStart
=
round
*
6
;
int
recmdStart
=
round
;
if
(
hotStart
>=
hotIds
.
size
()
&&
newestStart
>=
newestIds
.
size
()
&&
recmdStart
>=
recmdIds
.
size
())
{
break
;
}
retList
.
addAll
(
BizUtils
.
subList
(
hotIds
,
hotStart
,
hotStart
+
6
));
retList
.
addAll
(
BizUtils
.
subList
(
newestIds
,
newestStart
,
newestStart
+
3
));
retList
.
addAll
(
BizUtils
.
subList
(
hotIds
,
hotStart
,
hotStart
+
6
));
retList
.
addAll
(
BizUtils
.
subList
(
recmdIds
,
recmdStart
,
recmdStart
+
1
));
round
++;
...
...
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