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
91f5a2c5
Commit
91f5a2c5
authored
Dec 18, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
5a1b98d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
topic.py
search/views/topic.py
+15
-5
No files found.
search/views/topic.py
View file @
91f5a2c5
...
...
@@ -42,21 +42,31 @@ def get_home_recommend_topic_ids(user_id,session_id,offset,size,query=None):
for
have_read_item
in
redis_field_val_list
[
2
:]:
if
have_read_item
:
have_read_topic_id_set
=
have_read_topic_id_set
.
union
(
json
.
loads
(
have_read_item
))
#if user_id==-1:
# topic_id_list = list(set([item["id"] for item in topic_id_list]).difference(have_read_topic_id_set))
# 当前页小组数量
cur_page_group_num
=
0
# 当前页用户数量
cur_page_user_num
=
0
for
item
in
topic_id_list
:
if
item
[
"group_id"
]
in
have_read_group_id_set
:
unread_topic_id_list
.
append
(
item
)
else
:
if
item
[
"id"
]
not
in
have_read_topic_id_set
:
recommend_topic_ids
.
append
(
item
[
"id"
])
if
isinstance
(
item
[
"group_id"
],
int
)
and
item
[
"group_id"
]
>
0
:
if
isinstance
(
item
[
"group_id"
],
int
)
and
item
[
"group_id"
]
>
0
and
cur_page_group_num
<
(
size
*
0.9
):
have_read_group_id_set
.
add
(
item
[
"group_id"
])
have_read_topic_id_set
.
add
(
item
[
"id"
])
cur_page_group_num
+=
1
recommend_topic_ids
.
append
(
item
[
"id"
])
elif
item
[
"group_id"
]
<=
0
and
cur_page_user_num
<
(
size
*
0.1
):
cur_page_user_num
+=
1
recommend_topic_ids
.
append
(
item
[
"id"
])
else
:
unread_topic_id_list
.
append
(
item
)
if
len
(
recommend_topic_ids
)
>=
size
:
break
if
len
(
recommend_topic_ids
)
<
size
and
len
(
unread_topic_id_list
)
>
0
:
recommend_len
=
len
(
recommend_topic_ids
)
offi_unread_topic_id
=
[
item
[
"id"
]
for
item
in
unread_topic_id_list
[:(
size
-
recommend_len
)]]
...
...
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