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
ebe77e41
Commit
ebe77e41
authored
Aug 04, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热度算法优化-加大时间因子
parent
da281864
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
16 deletions
+16
-16
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+1
-1
TopicRankQo.java
...in/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
+1
-1
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+2
-2
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+11
-11
TimeUtils.java
...ice/src/main/java/com/tanpu/community/util/TimeUtils.java
+1
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
ebe77e41
...
...
@@ -42,7 +42,7 @@ public class ThemeAnalysDO {
private
Integer
viewCount
;
@ApiModelProperty
(
value
=
"距今时间"
)
private
Long
hour
sTillNow
;
private
Long
minute
sTillNow
;
@ApiModelProperty
(
value
=
"用户质量"
)
private
Double
userWeight
=
0.0
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
View file @
ebe77e41
...
...
@@ -38,7 +38,7 @@ public class TopicRankQo {
@ApiModelProperty
(
value
=
"话题下的帖子权重"
)
private
Double
themeWeight
;
private
Integer
hour
sTillNow
;
private
Integer
minute
sTillNow
;
private
Double
score
;
}
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
ebe77e41
...
...
@@ -260,7 +260,7 @@ public class RankService {
+
theme
.
getLikeCount
()
*
likeRaten
+
theme
.
getCollectCount
()
*
collectRate
+
Math
.
pow
(
theme
.
getUserWeight
(),
userWeightRate
);
double
score
=
(
w
+
initialWeight
)
/
Math
.
pow
(
theme
.
get
Hour
sTillNow
()
+
1
,
timeRate
);
double
score
=
(
w
+
initialWeight
)
/
Math
.
pow
(
theme
.
get
Minute
sTillNow
()
+
1
,
timeRate
);
theme
.
setScore
(
score
);
}
...
...
@@ -271,7 +271,7 @@ public class RankService {
topic
.
setScore
(
Double
.
MAX_VALUE
);
}
Double
socre
=
((
topic
.
getDisscussCount
()
*
topicDiscussRate
+
topic
.
getViewCount
()
*
topicViewRate
)
/
Math
.
pow
(
topic
.
get
Hour
sTillNow
()
+
1
,
topicTimeRate
))
/
Math
.
pow
(
topic
.
get
Minute
sTillNow
()
+
1
,
topicTimeRate
))
+
topic
.
getThemeWeight
()
*
topicThemeRate
;
topic
.
setScore
(
socre
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
ebe77e41
...
...
@@ -47,7 +47,7 @@ public class ConvertUtil {
}
ThemeAnalysDO
themeAnalysDO
=
new
ThemeAnalysDO
();
BeanUtils
.
copyProperties
(
themeEntity
,
themeAnalysDO
);
themeAnalysDO
.
set
HoursTillNow
(
TimeUtils
.
calHours
TillNow
(
themeEntity
.
getCreateTime
()));
themeAnalysDO
.
set
MinutesTillNow
(
TimeUtils
.
calMinute
TillNow
(
themeEntity
.
getCreateTime
()));
return
themeAnalysDO
;
}
...
...
@@ -64,7 +64,8 @@ public class ConvertUtil {
BeanUtils
.
copyProperties
(
entity
,
qo
);
// 抽取文本内容
List
<
ThemeContentQo
>
themeContentQos
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
new
TypeReference
<
List
<
ThemeContentQo
>>()
{});
List
<
ThemeContentQo
>
themeContentQos
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
new
TypeReference
<
List
<
ThemeContentQo
>>()
{
});
StringBuilder
sb
=
new
StringBuilder
();
themeContentQos
.
stream
().
filter
(
q
->
RelTypeEnum
.
TEXT
.
type
.
equals
(
q
.
getType
())).
forEach
(
q
->
{
sb
.
append
(
q
.
getValue
());
...
...
@@ -88,15 +89,15 @@ public class ConvertUtil {
TopicRankQo
topicRankQo
=
new
TopicRankQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicRankQo
);
//2小时内发帖,添加新话题标签
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())<
120
)
{
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
120
)
{
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
}
topicRankQo
.
set
HoursTillNow
((
int
)
TimeUtils
.
calHours
TillNow
(
topicEntity
.
getCreateTime
()));
topicRankQo
.
set
MinutesTillNow
((
int
)
TimeUtils
.
calMinute
TillNow
(
topicEntity
.
getCreateTime
()));
return
topicRankQo
;
}
public
static
List
<
TopicRankQo
>
topicEntityToHotQos
(
List
<
TopicEntity
>
topicEntities
)
{
if
(
topicEntities
==
null
)
{
if
(
topicEntities
==
null
)
{
return
Collections
.
emptyList
();
}
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToHotQo
).
collect
(
Collectors
.
toList
());
...
...
@@ -153,13 +154,13 @@ public class ConvertUtil {
.
build
());
}
}
else
if
((
content
.
getType
().
equals
(
RelTypeEnum
.
SINGLE_IMG
.
type
)))
{
if
(
StringUtils
.
isEmpty
(
content
.
getValue
())){
if
(
StringUtils
.
isEmpty
(
content
.
getValue
()))
{
list
.
add
(
ThemeAttachmentEntity
.
builder
()
.
attachType
(
Integer
.
valueOf
(
content
.
getType
()))
.
attachId
(
content
.
getValue
())
.
themeId
(
themeId
)
.
build
());
}
else
{
}
else
{
List
<
ImagesDTO
>
imgList
=
content
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
list
.
add
(
ThemeAttachmentEntity
.
builder
()
...
...
@@ -170,7 +171,7 @@ public class ConvertUtil {
}
}
}
else
{
}
else
{
}
}
...
...
@@ -211,9 +212,9 @@ public class ConvertUtil {
.
build
();
}
public
static
FileUploadResp
fileRecordEntity2Resp
(
FileRecordEntity
entity
){
public
static
FileUploadResp
fileRecordEntity2Resp
(
FileRecordEntity
entity
)
{
FileUploadResp
resp
=
new
FileUploadResp
();
BeanUtils
.
copyProperties
(
entity
,
resp
);
BeanUtils
.
copyProperties
(
entity
,
resp
);
String
extInfo
=
entity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
...
...
@@ -224,5 +225,4 @@ public class ConvertUtil {
}
}
community-service/src/main/java/com/tanpu/community/util/TimeUtils.java
View file @
ebe77e41
...
...
@@ -60,7 +60,7 @@ public class TimeUtils {
return
between
.
toDays
();
}
//计算迄今
天
数
//计算迄今
小时
数
public
static
long
calHoursTillNow
(
LocalDateTime
start
)
{
Duration
between
=
Duration
.
between
(
start
,
LocalDateTime
.
now
());
return
between
.
toHours
();
...
...
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