Commit 9d693cfb authored by 段英荣's avatar 段英荣

modify

parent ce68c272
...@@ -48,7 +48,7 @@ class GroupUtils(object): ...@@ -48,7 +48,7 @@ class GroupUtils(object):
return {"total_count":0, "hits":[]} return {"total_count":0, "hits":[]}
@classmethod @classmethod
def get_hot_group_recommend_results(cls,offset,size): def get_hot_group_recommend_result_list(cls,offset,size):
try: try:
q = dict() q = dict()
q["query"] = { q["query"] = {
...@@ -67,10 +67,16 @@ class GroupUtils(object): ...@@ -67,10 +67,16 @@ class GroupUtils(object):
"include":["id"] "include":["id"]
} }
return ESPerform.get_search_results(ESPerform.get_cli(),"group",q,offset,size) result_dict = ESPerform.get_search_results(ESPerform.get_cli(),"group",q,offset,size)
group_ids_list = []
if len(result_dict["hits"]) > 0:
group_ids_list = [item["_source"]["id"] for item in result_dict["hits"]]
return group_ids_list
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"total_count":0, "hits":[]} return []
@classmethod @classmethod
def get_user_attention_group_list(cls,user_id,offset,size): def get_user_attention_group_list(cls,user_id,offset,size):
......
...@@ -44,10 +44,10 @@ def group_sort(user_id=-1,sort_type=GroupSortTypes.HOT_RECOMMEND,offset=0,size=1 ...@@ -44,10 +44,10 @@ def group_sort(user_id=-1,sort_type=GroupSortTypes.HOT_RECOMMEND,offset=0,size=1
""" """
try: try:
if sort_type==GroupSortTypes.HOT_RECOMMEND: if sort_type==GroupSortTypes.HOT_RECOMMEND:
result_dict = GroupUtils.get_hot_group_recommend_results(offset,size) group_ids_list = GroupUtils.get_hot_group_recommend_result_list(offset,size)
group_ids_list = [item.id for item in result_dict["hits"]]
return {"group_recommend_ids":group_ids_list} return {"group_recommend_ids":group_ids_list}
elif sort_type==GroupSortTypes.ATTENTION_RECOMMEND: elif sort_type==GroupSortTypes.ATTENTION_RECOMMEND:
attention_group_list = GroupUtils.get_user_attention_group_list(user_id,offset,size) attention_group_list = GroupUtils.get_user_attention_group_list(user_id,offset,size)
if len(attention_group_list)==0: if len(attention_group_list)==0:
......
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