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
594e922c
Commit
594e922c
authored
Jul 27, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空值修复
parent
3b52355a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
10 deletions
+146
-10
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+3
-2
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+24
-6
VisitSummaryService.java
...java/com/tanpu/community/service/VisitSummaryService.java
+6
-2
application-test.yml
community-service/src/main/resources/application-test.yml
+113
-0
No files found.
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
594e922c
...
...
@@ -112,6 +112,8 @@ public class RankService {
if
(
topicRankQos
.
size
()
==
0
)
{
return
;
}
List
<
String
>
topicIds
=
topicRankQos
.
stream
().
map
(
TopicRankQo:
:
getTopicId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Integer
>
countMapByTargetIds
=
visitSummaryService
.
getCountMapByTargetIds
(
topicIds
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
for
(
TopicRankQo
topic
:
topicRankQos
)
{
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
());
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
...
...
@@ -120,8 +122,7 @@ public class RankService {
continue
;
}
// 浏览量
// todo 批量查询
Integer
topicPV
=
visitSummaryService
.
queryTopicDetailVisit
(
topic
.
getTopicId
());
Integer
topicPV
=
countMapByTargetIds
.
getOrDefault
(
topic
.
getTopicId
(),
0
);
Integer
themePV
=
visitSummaryService
.
queryThemeVisit
(
themeIds
);
topic
.
setViewCount
(
topicPV
+
themePV
);
//讨论数=发布主题贴数+回复总数
...
...
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
594e922c
...
...
@@ -66,12 +66,16 @@ public class RecommendService {
List
<
String
>
recThemeIds
=
getPythonRecommendList
(
userId
);
// 混合 如果重新搜索,则刷新返回id
Set
<
String
>
returned
Ids
=
(
StringUtils
.
isEmpty
(
lastId
))
||
!
returnedIdsMap
.
containsKey
(
userId
)
Set
<
String
>
viewedTheme
Ids
=
(
StringUtils
.
isEmpty
(
lastId
))
||
!
returnedIdsMap
.
containsKey
(
userId
)
||
returnedIdsMap
.
get
(
userId
)
==
null
?
new
HashSet
<>()
:
returnedIdsMap
.
get
(
userId
);
viewedThemeIds
.
addAll
(
visitSummaryService
.
queryUseVisited
(
userId
));
List
<
String
>
result
=
new
ArrayList
<>();
getResultList
(
hotThemeIds
,
0
,
newThemeIds
,
0
,
recThemeIds
,
0
,
returnedIds
,
result
,
pageSize
,
userId
);
getResultList
(
hotThemeIds
,
0
,
newThemeIds
,
0
,
recThemeIds
,
0
,
viewedThemeIds
,
result
,
pageSize
,
userId
);
// List<String> result = mergeList(hotThemeIds, newThemeIds, recThemeIds,viewedThemeIds);
result
=
result
.
stream
().
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
//记录已返回主题id
if
(
StringUtils
.
isEmpty
(
lastId
))
{
returnedIdsMap
.
put
(
userId
,
new
HashSet
<>(
result
));
...
...
@@ -127,8 +131,10 @@ public class RecommendService {
}
private
List
<
String
>
mergeList
(
List
<
String
>
hotThemeIds
,
List
<
String
>
newThemeIds
,
List
<
String
>
recThemeIds
)
{
// 合并,去重
private
List
<
String
>
mergeList
(
List
<
String
>
hotThemeIds
,
List
<
String
>
newThemeIds
,
List
<
String
>
recThemeIds
,
Set
<
String
>
set
)
{
ArrayList
<
String
>
result
=
new
ArrayList
<>();
// 3个集合的指针
Integer
hotIdx
=
0
;
Integer
newIdx
=
0
;
Integer
recIdx
=
0
;
...
...
@@ -139,19 +145,31 @@ public class RecommendService {
String
id
;
while
(
hotTimes
>
0
&&
hotThemeIds
.
size
()
>
hotIdx
)
{
id
=
hotThemeIds
.
get
(
hotIdx
);
if
(!
set
.
contains
(
id
)){
result
.
add
(
id
);
set
.
add
(
id
);
}
hotIdx
++;
hotTimes
--;
}
while
(
newTimes
>
0
&&
newThemeIds
.
size
()
>
newIdx
)
{
id
=
newThemeIds
.
get
(
newIdx
);
if
(!
set
.
contains
(
id
)){
result
.
add
(
id
);
set
.
add
(
id
);
}
newIdx
++;
newTimes
--;
}
while
(
recTimes
>
0
&&
recThemeIds
.
size
()
>
recIdx
)
{
id
=
recThemeIds
.
get
(
recIdx
);
if
(!
set
.
contains
(
id
)){
result
.
add
(
id
);
set
.
add
(
id
);
}
recIdx
++;
recTimes
--;
}
...
...
community-service/src/main/java/com/tanpu/community/service/VisitSummaryService.java
View file @
594e922c
...
...
@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -92,9 +93,12 @@ public class VisitSummaryService {
}
//统计主题集合的浏览量
public
Map
<
String
,
Integer
>
getCountMapByThemeIds
(
List
<
String
>
themeIds
,
VisitTypeEnum
type
)
{
public
Map
<
String
,
Integer
>
getCountMapByTargetIds
(
List
<
String
>
refIds
,
VisitTypeEnum
type
)
{
if
(
CollectionUtils
.
isEmpty
(
refIds
)){
return
new
HashMap
<>();
}
LambdaQueryWrapper
<
VisitSummaryEntity
>
wrapper
=
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
in
(
VisitSummaryEntity:
:
getRefId
,
theme
Ids
))
.
in
(
VisitSummaryEntity:
:
getRefId
,
ref
Ids
))
.
eq
(
VisitSummaryEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
)
.
eq
(
VisitSummaryEntity:
:
getRefType
,
type
.
getCode
())
.
groupBy
(
VisitSummaryEntity:
:
getRefId
);
...
...
community-service/src/main/resources/application-test.yml
0 → 100644
View file @
594e922c
apollo.bootstrap.enabled
:
true
#app.id: tanpu-community
#apollo:
# meta: http://dev-apollo.tamp-innner.com:8080
# cacheDir: ./apollocache/
# bootstrap:
# namespaces: application.yml
server
:
port
:
8060
servlet
:
context-path
:
/community
spring.datasource
:
community
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
initialSize
:
2
user
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
initialSize
:
2
jydb
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_jydb?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
initialSize
:
2
fund
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_fund?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
initialSize
:
2
spring.redis
:
host
:
118.190.63.109
port
:
56379
password
:
qimeng123
timeout
:
2000
max-active
:
5
max-wait
:
5
max-idle
:
5
jedis
:
pool
:
max-active
:
3
max-idle
:
3
min-idle
:
3
spring.kafka
:
bootstrap-servers
:
118.190.63.109:9092
consumer
:
group-id
:
tp_group_new_community
auto-offset-reset
:
latest
fetch-min-size
:
64
fetch-max-wait
:
500
max-poll-records
:
500
key-deserializer
:
org.apache.kafka.common.serialization.StringDeserializer
value-deserializer
:
org.apache.kafka.common.serialization.StringDeserializer
producer
:
acks
:
1
batch-size
:
10000
key-serializer
:
org.apache.kafka.common.serialization.StringSerializer
value-serializer
:
org.apache.kafka.common.serialization.StringSerializer
spring
:
sleuth
:
enabled
:
false
zipkin
:
enabled
:
false
aliyun
:
oss
:
endpoint
:
http://oss-cn-shanghai.aliyuncs.com
accessId
:
LTAIAKEzVydP0Q9P
accessSK
:
59V9ke9txaIFzWxHFKTb1eoOOpmKpJ
bucketName
:
tamp-sit
es
:
host
:
42.194.224.208
port
:
9200
userName
:
1
userPasswd
:
2
tencent
:
cloud
:
secretId
:
AKIDTjjV2IhK4ZKBm8z5g14vPedNSJuFnTIq
secretKey
:
PaVBZfeQwDVXKr7TZOzM6c9VZNwGJGyA
region
:
ap-shanghai
recommend
:
ratio
:
#主题推荐比例(热门、最新、机器学习)
hot
:
3
new
:
2
python
:
1
python
:
enable
:
false
url
:
http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ 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