Commit d6089859 authored by 段英荣's avatar 段英荣

add test score

parent bab5269d
...@@ -93,7 +93,7 @@ class TopicUtils(object): ...@@ -93,7 +93,7 @@ class TopicUtils(object):
return [] return []
@classmethod @classmethod
def get_recommend_topic_ids(cls,user_id,offset,size,query=None,query_type=TopicPageType.FIND_PAGE,filter_topic_id_list=[]): def get_recommend_topic_ids(cls,user_id,offset,size,query=None,query_type=TopicPageType.FIND_PAGE,filter_topic_id_list=[],test_score=False):
""" """
:需增加打散逻辑 :需增加打散逻辑
:remark:获取首页推荐帖子列表 :remark:获取首页推荐帖子列表
...@@ -254,11 +254,19 @@ class TopicUtils(object): ...@@ -254,11 +254,19 @@ class TopicUtils(object):
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q, result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q,
offset=offset, size=size) offset=offset, size=size)
if not test_score:
topic_id_dict = dict() topic_id_dict = dict()
for item in result_dict["hits"]: for item in result_dict["hits"]:
topic_id_dict[item["_source"]["id"]] = [item["_source"]["group_id"],item["_source"]["user_id"]] topic_id_dict[item["_source"]["id"]] = [item["_source"]["group_id"],item["_source"]["user_id"]]
return topic_id_dict return topic_id_dict
else:
topic_id_dict = dict()
for item in result_dict["hits"]:
topic_id_dict[item["_source"]["id"]] = [item["_source"]["group_id"],item["_source"]["user_id"],item["_score"]]
return topic_id_dict
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return dict() return dict()
......
...@@ -127,7 +127,7 @@ class Command(BaseCommand): ...@@ -127,7 +127,7 @@ class Command(BaseCommand):
def generate_topic_score_detail(self): def generate_topic_score_detail(self):
try: try:
topic_id_dict = TopicUtils.get_recommend_topic_ids(-1, 0, 500) topic_id_dict = TopicUtils.get_recommend_topic_ids(-1, 0, 500,test_score=True)
for topic_id in topic_id_dict: for topic_id in topic_id_dict:
offline_score = 0.0 offline_score = 0.0
...@@ -182,8 +182,8 @@ class Command(BaseCommand): ...@@ -182,8 +182,8 @@ class Command(BaseCommand):
if user_is_shadow: if user_is_shadow:
offline_score = offline_score * 0.5 offline_score = offline_score * 0.5
logging.info("test_score,offline_score:%f,user_is_recommend:%f,group_is_recommend:%f,topic_level_score:%f,exposure_score:%f,uv_score:%f" logging.info("test_score######score:%f,offline_score:%f,user_is_recommend:%f,group_is_recommend:%f,topic_level_score:%f,exposure_score:%f,uv_score:%f"
% (offline_score,user_is_recommend,group_is_recommend,topic_level_score,exposure_score,uv_score)) % (topic_id_dict[topic_id][2],offline_score,user_is_recommend,group_is_recommend,topic_level_score,exposure_score,uv_score))
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
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