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

Merge branch '720_pictorial' into 'master'

画报新增一个我的投稿tab

See merge request alpha/physical!385
parents c4378545 2138e3fc
......@@ -296,7 +296,7 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
es_cli_obj = ESPerform.get_cli()
result_dict = ESPerform.get_search_results(es_cli_obj, "topic", q, offset, size)
logging.info("get pictorial_topic_sort res:%s" % result_dict)
# logging.info("get pictorial_topic_sort res:%s" % result_dict)
for item in result_dict["hits"]:
topic_id = item["_source"]["id"]
......@@ -331,3 +331,71 @@ def search_physical(query="", offset=0, size=10):
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"search_pictorial_ids": []}
@bind("physical/search/pictorialid_topic")
def pictorial_topic_sort_peoplehot(pictorial_id=-1, user_id=-1, offset=0, size=10):
try:
if not isinstance(pictorial_id, int):
pictorial_id = -1
results = pictorial_topic_sort(pictorial_id=pictorial_id, size=100)
pict_pictorial_ids_list = results["pict_pictorial_ids_list"]
logging.info("get pict_pictorial_ids_list res:%s" % pict_pictorial_ids_list)
q = {
"query": {
"bool": {
"must": [
{"term": {"is_online": True}},
{"term": {"is_deleted": False}},
{"term": {"pictorial_id": pictorial_id}},
{"term": {"user_id": user_id}}
]
}
},
"sort": [
{"related_billboard.total_vote_cnt": {
"order": "desc",
"nested_path": "related_billboard",
"missing": "_last",
"nested_filter": {
"term": {
"related_billboard.pictorial_id": pictorial_id
}
}
}},
{"create_time": {"order": "desc"}}
]
}
# 获取es链接对象
es_cli_obj = ESPerform.get_cli()
result_dict = ESPerform.get_search_results(es_cli_obj, "topic", q, offset, size)
user_pict_pictorial_ids_list = []
for item in result_dict["hits"]:
topic_id = item["_source"]["id"]
user_pict_pictorial_ids_list.append(topic_id)
logging.info("get user_pict_pictorial_ids_list res:%s" % user_pict_pictorial_ids_list)
pictorial_user_topicid_list = list()
for user_id_topic in user_pict_pictorial_ids_list:
if user_id_topic in pict_pictorial_ids_list:
topic_sort = pict_pictorial_ids_list.index(user_id_topic)
pictorial_user_topicid_list.append({"topic_id": user_id_topic, "topic_sort": topic_sort + 1})
else:
index = user_pict_pictorial_ids_list.index(user_id_topic)
pictorial_user_topicid_list.append({"topic_id": user_id_topic, "topic_sort": 100 + index})
return {"pictorial_user_topicid_list": pictorial_user_topicid_list}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"pict_pictorial_ids_list": []}
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