Commit 3298b126 authored by Kai's avatar Kai

update

parent 69fa212a
......@@ -46,7 +46,7 @@ def get_discover_page_topic_ids(user_id, device_id, size, query_type=TopicPageTy
def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query=None,
query_type=TopicPageType.HOME_RECOMMEND):
query_type=TopicPageType.HOME_RECOMMEND,promote_topic_list = []):
try:
if query is None:
if user_id>0:
......@@ -117,28 +117,28 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
#
# for topic_id in promote_recommend_topic_id_list:
# have_read_topic_id_list_add_promote.append(topic_id)
have_read_topic_id_list.extend(promote_topic_list)
topic_id_list = list()
rank_topic_id_list = TopicUtils.get_recommend_topic_ids(user_id=user_id, tag_id=tag_id, offset=0, size=size,
single_size=size,query=query, query_type=query_type,
filter_topic_id_list=have_read_topic_id_list,
index_type="topic-high-star",routing="4,5,6",attention_tag_list=attention_tag_list,linucb_user_id_list=recommend_topic_user_list)
if len(recommend_topic_list) == 6 and query is None:
if (size < 11):
topic_id_list.extend(rank_topic_id_list[0:3])
topic_id_list.extend(recommend_topic_list[0:3])
topic_id_list.extend(rank_topic_id_list[3:size])
topic_id_list.extend(recommend_topic_list[3:6])
else:
topic_id_list.extend(rank_topic_id_list[0:size - 7])
topic_id_list.extend(recommend_topic_list[0:3])
topic_id_list.extend(rank_topic_id_list[size - 7:size])
topic_id_list.extend(recommend_topic_list[3:6])
else:
topic_id_list.extend(rank_topic_id_list)
have_read_topic_id_list.extend(topic_id_list)
# if len(recommend_topic_list) == 6 and query is None:
# if (size < 11):
# topic_id_list.extend(rank_topic_id_list[0:3])
# topic_id_list.extend(recommend_topic_list[0:3])
# topic_id_list.extend(rank_topic_id_list[3:size])
# topic_id_list.extend(recommend_topic_list[3:6])
# else:
# topic_id_list.extend(rank_topic_id_list[0:size - 7])
# topic_id_list.extend(recommend_topic_list[0:3])
# topic_id_list.extend(rank_topic_id_list[size - 7:size])
# topic_id_list.extend(recommend_topic_list[3:6])
# else:
# topic_id_list.extend(rank_topic_id_list)
have_read_topic_id_list.extend(rank_topic_id_list)
if len(have_read_topic_id_list) > 30000:
cut_len = len(have_read_topic_id_list)-30000
have_read_topic_id_list = have_read_topic_id_list[cut_len:]
......@@ -149,7 +149,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# 每个session key保存30天
redis_client.expire(redis_key, 60 * 60 * 24 * 30)
return topic_id_list
return recommend_topic_list,rank_topic_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
......@@ -165,7 +165,7 @@ def query_tag_id_by_topic(offset=0, size=10, topic_id_list=[], user_id=-1):
@bind("physical/search/home_recommend")
def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=TopicPageType.HOME_RECOMMEND):
def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=TopicPageType.HOME_RECOMMEND,promote_topic_list=[]):
"""
:remark:首页推荐,目前只推荐日记
:param session_id:
......@@ -181,7 +181,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=Topic
device_id = ""
recommend_topic_ids = list()
rank_topic_ids = list()
es_node_load_high_flag = False
# try:
# es_node_load_high_flag = ESPerform.if_es_node_load_high(ESPerform.get_cli())
......@@ -202,10 +202,10 @@ def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=Topic
recommend_topic_ids = have_read_topic_id_list[0:size]
else:
recommend_topic_ids = get_home_recommend_topic_ids(user_id, device_id, tag_id=0, offset=0, size=size,
query_type=query_type)
recommend_topic_ids,rank_topic_ids = get_home_recommend_topic_ids(user_id, device_id, tag_id=0, offset=0, size=size,
query_type=query_type,promote_topic_list=promote_topic_list)
return {"recommend_topic_ids": recommend_topic_ids}
return {"linucb_topic_ids": recommend_topic_ids,"rank_topic_ids":rank_topic_ids}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"recommend_topic_ids": []}
......
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