Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
4bd61032
Commit
4bd61032
authored
Apr 17, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify bug
parent
d54d5d2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
topic.py
search/views/topic.py
+13
-10
No files found.
search/views/topic.py
View file @
4bd61032
...
...
@@ -63,27 +63,31 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
redis_field_list
=
[
b
'have_read_topic_list'
]
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_list
)
# 获取已读帖子
have_read_topic_id_list
=
list
()
if
redis_field_val_list
[
0
]:
if
query
is
None
:
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
else
:
if
offset
>
0
:
# 首次搜索时不需要过滤已读
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
# linucb 推荐帖子
topic_recommend_redis_key
=
"physical:linucb:topic_recommend:device_id:"
+
str
(
device_id
)
recommend_topic_list
=
list
()
recommend_topic_dict
=
redis_client
.
hgetall
(
topic_recommend_redis_key
)
if
b
"data"
in
recommend_topic_dict
:
recommend_topic_id_list
=
json
.
loads
(
recommend_topic_dict
[
b
"data"
])
# 推荐帖子是强插的,要保证推荐帖子不在已读里
recommend_topic_id_list
=
list
(
set
(
recommend_topic_id_list
)
-
set
(
have_read_topic_id_list
))
cursor
=
int
(
str
(
recommend_topic_dict
[
b
"cursor"
],
encoding
=
"utf-8"
))
newcursor
=
cursor
+
6
if
len
(
recommend_topic_id_list
)
>
newcursor
:
recommend_topic_list
=
recommend_topic_id_list
[
cursor
:
newcursor
]
redis_client
.
hset
(
topic_recommend_redis_key
,
"cursor"
,
newcursor
)
have_read_topic_id_list
=
list
()
if
redis_field_val_list
[
0
]:
if
query
is
None
:
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
else
:
if
offset
>
0
:
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
user_similar_score_redis_key
=
"physical:user_similar_score:user_id:"
+
str
(
user_id
)
redis_user_similar_score_redis_val
=
redis_client
.
get
(
user_similar_score_redis_key
)
user_similar_score_redis_list
=
json
.
loads
(
...
...
@@ -92,7 +96,6 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
redis_tag_data
=
redis_client
.
hget
(
"physical:linucb:register_user_tag_info"
,
user_id
)
attention_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
logging
.
info
(
"attention_tag_list:
%
s"
%
(
str
(
attention_tag_list
)))
if
len
(
recommend_topic_list
)
>
0
:
size
=
size
-
len
(
recommend_topic_list
)
have_read_topic_id_list
.
extend
(
recommend_topic_list
)
...
...
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