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
c0a78e0e
Commit
c0a78e0e
authored
Aug 04, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化正文时间
parent
1bc324ab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
5 deletions
+46
-5
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+4
-0
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+20
-0
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+4
-3
TimeUtils.java
...ice/src/main/java/com/tanpu/community/util/TimeUtils.java
+5
-0
application-dev.yml
community-service/src/main/resources/application-dev.yml
+12
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
c0a78e0e
...
@@ -58,7 +58,7 @@ public class ThemeAnalysDO {
...
@@ -58,7 +58,7 @@ public class ThemeAnalysDO {
double
collectRatio
=
3
;
double
collectRatio
=
3
;
double
userWeightRatio
=
0.8
;
double
userWeightRatio
=
0.8
;
double
initialWeight
=
1.0
;
double
initialWeight
=
1.0
;
double
timeRation
=
0.
3
;
double
timeRation
=
0.
2
;
// 质量=帖子质量+用户质量
// 质量=帖子质量+用户质量
double
w
=
viewCount
*
viewRatio
+
forwardCount
*
forwardRatio
+
commentCount
*
commentRatio
double
w
=
viewCount
*
viewRatio
+
forwardCount
*
forwardRatio
+
commentCount
*
commentRatio
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
c0a78e0e
...
@@ -43,6 +43,7 @@ import com.tanpu.community.util.BizUtils;
...
@@ -43,6 +43,7 @@ import com.tanpu.community.util.BizUtils;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.RankUtils
;
import
com.tanpu.community.util.RankUtils
;
import
com.tanpu.community.util.TencentcloudUtils
;
import
com.tanpu.community.util.TencentcloudUtils
;
import
com.tanpu.community.util.TimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.collections4.ListUtils
;
...
@@ -468,6 +469,9 @@ public class ThemeManager {
...
@@ -468,6 +469,9 @@ public class ThemeManager {
//转发、收藏、点赞
//转发、收藏、点赞
buildThemeQoExtraInfo
(
themeQo
);
buildThemeQoExtraInfo
(
themeQo
);
//时间重制
themeQo
.
setUpToNowTime
(
TimeUtils
.
format
(
themeEntity
.
getCreateTime
()));
return
themeQo
;
return
themeQo
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
c0a78e0e
...
@@ -15,6 +15,7 @@ import com.tanpu.community.util.TimeUtils;
...
@@ -15,6 +15,7 @@ import com.tanpu.community.util.TimeUtils;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -29,6 +30,25 @@ import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USE
...
@@ -29,6 +30,25 @@ import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USE
@Service
@Service
public
class
RankService
{
public
class
RankService
{
@Value
(
"${rank.theme.viewRatio:0.1}"
)
public
Double
viewRatio
;
@Value
(
"${rank.theme.forwardRatio:3}"
)
public
Double
forwardRatio
;
@Value
(
"${rank.theme.commentRatio:2}"
)
public
Double
commentRatio
;
@Value
(
"${rank.theme.likeRation:3}"
)
public
Double
likeRation
;
@Value
(
"${rank.theme.collectRatio:3}"
)
public
Double
collectRatio
;
@Value
(
"${rank.theme.userWeightRatio:0.9}"
)
public
Double
userWeightRatio
;
@Value
(
"${rank.theme.initialWeight:1.0}"
)
public
Double
initialWeight
;
@Value
(
"${rank.theme.timeRation:0.2}"
)
public
Double
timeRation
;
@Autowired
@Autowired
private
ThemeService
themeService
;
private
ThemeService
themeService
;
@Autowired
@Autowired
...
...
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
c0a78e0e
...
@@ -172,9 +172,10 @@ public class RecommendService {
...
@@ -172,9 +172,10 @@ public class RecommendService {
int
round
=
0
;
int
round
=
0
;
while
(
true
)
{
while
(
true
)
{
int
hotStart
=
round
*
3
;
int
newestStart
=
round
*
6
;
int
newestStart
=
round
*
newRatio
;
int
recmdStart
=
round
;
int
hotStart
=
round
*
hotRatio
;
int
recmdStart
=
round
*
pythonRatio
;
if
(
hotStart
>=
hotIds
.
size
()
&&
newestStart
>=
newestIds
.
size
()
&&
recmdStart
>=
recmdIds
.
size
())
{
if
(
hotStart
>=
hotIds
.
size
()
&&
newestStart
>=
newestIds
.
size
()
&&
recmdStart
>=
recmdIds
.
size
())
{
break
;
break
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/util/TimeUtils.java
View file @
c0a78e0e
...
@@ -37,6 +37,11 @@ public class TimeUtils {
...
@@ -37,6 +37,11 @@ public class TimeUtils {
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
}
//格式化时间
public
static
String
format
(
LocalDateTime
start
)
{
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
//计算迄今分钟
//计算迄今分钟
public
static
long
calMinuteTillNow
(
LocalDateTime
start
)
{
public
static
long
calMinuteTillNow
(
LocalDateTime
start
)
{
Duration
between
=
Duration
.
between
(
start
,
LocalDateTime
.
now
());
Duration
between
=
Duration
.
between
(
start
,
LocalDateTime
.
now
());
...
...
community-service/src/main/resources/application-dev.yml
View file @
c0a78e0e
...
@@ -94,4 +94,15 @@ recommend:
...
@@ -94,4 +94,15 @@ recommend:
python
:
1
python
:
1
python
:
python
:
enable
:
false
enable
:
false
url
:
http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
url
:
http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
rank
:
theme
:
viewRatio
:
0.1
forwardRatio
:
3
commentRatio
:
2
likeRation
:
1
collectRatio
:
3
userWeightRatio
:
0.9
initialWeight
:
1.0
timeRation
:
0.2
\ No newline at end of file
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