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
alpha
physical
Commits
582e8a03
Commit
582e8a03
authored
Feb 02, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'only_no_see' into 'master'
filter have read topic id list See merge request
!102
parents
da3b1520
428e2b15
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
topic.py
search/views/topic.py
+11
-6
No files found.
search/views/topic.py
View file @
582e8a03
...
...
@@ -59,12 +59,12 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_list
)
recommend_topic_ids
=
[]
have_read_topic_id_
set
=
se
t
()
have_read_topic_id_
list
=
lis
t
()
if
redis_field_val_list
[
0
]:
have_read_topic_id_
set
=
se
t
(
json
.
loads
(
redis_field_val_list
[
0
]))
have_read_topic_id_
list
=
lis
t
(
json
.
loads
(
redis_field_val_list
[
0
]))
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
,
offset
,
size
*
size
,
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_set
)
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
,
offset
,
size
*
size
,
query
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
have_read_topic_id_set
)
have_read_group_id_set
=
set
()
have_read_user_id_set
=
set
()
unread_topic_id_dict
=
dict
()
...
...
@@ -81,13 +81,14 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
if
isinstance
(
topic_id_dict
[
topic_id
][
0
],
int
)
and
topic_id_dict
[
topic_id
][
0
]
>
0
and
cur_page_group_num
<
(
size
*
0.9
):
have_read_group_id_set
.
add
(
topic_id_dict
[
topic_id
][
0
])
have_read_user_id_set
.
add
(
topic_id_dict
[
topic_id
][
1
])
have_read_topic_id_
set
.
ad
d
(
topic_id
)
have_read_topic_id_
list
.
appen
d
(
topic_id
)
cur_page_group_num
+=
1
recommend_topic_ids
.
append
(
topic_id
)
elif
topic_id_dict
[
topic_id
]
and
cur_page_user_num
<
(
size
*
0.1
):
have_read_user_id_set
.
add
(
topic_id_dict
[
topic_id
][
1
])
cur_page_user_num
+=
1
recommend_topic_ids
.
append
(
topic_id
)
have_read_topic_id_list
.
append
(
topic_id
)
else
:
unread_topic_id_dict
[
topic_id
]
=
topic_id_dict
[
topic_id
]
...
...
@@ -99,11 +100,15 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
for
unread_topic_id
in
unread_topic_id_dict
:
if
len
(
recommend_topic_ids
)
<
size
:
recommend_topic_ids
.
append
(
unread_topic_id
)
have_read_
user_id_set
.
ad
d
(
unread_topic_id
)
have_read_
topic_id_list
.
appen
d
(
unread_topic_id
)
else
:
break
if
len
(
have_read_topic_id_list
)
>
10000
:
cut_len
=
len
(
have_read_topic_id_list
)
-
10000
have_read_topic_id_list
=
have_read_topic_id_list
[
cut_len
:]
redis_dict
=
{
"have_read_topic_list"
:
json
.
dumps
(
list
(
have_read_user_id_set
)
),
"have_read_topic_list"
:
json
.
dumps
(
have_read_topic_id_list
),
}
redis_client
.
hmset
(
redis_key
,
redis_dict
)
# 每个session key保存15分钟
...
...
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