Commit 91f5a2c5 authored by 段英荣's avatar 段英荣

modify

parent 5a1b98d0
......@@ -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)]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment