Commit 6d7366dc authored by lixiaofang's avatar lixiaofang

去掉控画报的

parent c1b48f9f
......@@ -47,7 +47,7 @@ class GroupUtils(object):
return {"total_count": 0, "hits": []}
@classmethod
def get_hot_pictorial_recommend_result_list(cls,offset,size,es_cli_obj=None,attention_tag_list=[]):
def get_hot_pictorial_recommend_result_list(cls, offset, size, es_cli_obj=None, attention_tag_list=[]):
try:
if not es_cli_obj:
es_cli_obj = ESPerform.get_cli()
......@@ -55,10 +55,10 @@ class GroupUtils(object):
functions_list = list()
for tag_id in attention_tag_list:
functions_list.append({
"filter":{
"constant_score":{
"filter":{
"term":{
"filter": {
"constant_score": {
"filter": {
"term": {
"tag_id": tag_id
}
}
......@@ -67,7 +67,7 @@ class GroupUtils(object):
"weight": 20
})
if len(functions_list)>=20:
if len(functions_list) >= 20:
break
functions_list.append(
......@@ -82,17 +82,17 @@ class GroupUtils(object):
}
)
q = {
"query":{
"function_score":{
"query":{
"bool":{
"filter":[
"query": {
"function_score": {
"query": {
"bool": {
"filter": [
{"term": {"is_online": True}},
{"term": {"is_deleted": False}},
{"term": {"effective": True}}
],
"must_not":[
{"term":{"is_default":1}}
"must_not": [
{"term": {"is_default": 1}}
]
}
},
......@@ -116,16 +116,16 @@ class GroupUtils(object):
}
},
{
"_score":{
"_score": {
"order": "desc"
}
}
]
q["_source"] = {
"includes":["id"]
"includes": ["id"]
}
result_dict = ESPerform.get_search_results(es_cli_obj,"pictorial",q,offset,size)
result_dict = ESPerform.get_search_results(es_cli_obj, "pictorial", q, offset, size)
pictorial_ids_list = []
if len(result_dict["hits"]) > 0:
......@@ -153,7 +153,7 @@ class GroupUtils(object):
{"term": {"is_online": True}},
{"term": {"user_id": user_id}},
{"term": {"is_deleted": False}},
{"term":{"effective":True}}
{"term": {"effective": True}}
]
}
}
......@@ -171,7 +171,6 @@ class GroupUtils(object):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
@classmethod
def get_pictorial_ids_by_aggs(cls, pictorial_ids_list, es_cli_obj=None):
"""
......
......@@ -54,11 +54,12 @@ def pictorial_sort(user_id=-1, sort_type=GroupSortTypes.HOT_RECOMMEND, offset=0,
if sort_type == GroupSortTypes.HOT_RECOMMEND:
# 用户关注标签
attention_tag_list = list()
if user_id>0:
if user_id > 0:
redis_tag_data = redis_client.hget("physical:linucb:register_user_tag_info", user_id)
attention_tag_list = json.loads(redis_tag_data) if redis_tag_data else []
pictorial_ids_list = GroupUtils.get_hot_pictorial_recommend_result_list(offset, size, es_cli_obj,attention_tag_list)
pictorial_ids_list = GroupUtils.get_hot_pictorial_recommend_result_list(offset, size, es_cli_obj,
attention_tag_list)
return {"pictorial_recommend_ids": pictorial_ids_list}
elif sort_type == GroupSortTypes.ATTENTION_RECOMMEND:
......@@ -173,6 +174,13 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
"term": {
"is_deleted": False
}
}, {
"range": {
"topic_id_list": {
"gte": 0
}
}
}]
}
}
......@@ -221,33 +229,33 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
user_id = -1
q = {
"query":{
"bool":{
"must":[
{"term":{"pictorial_id": pictorial_id}},
"query": {
"bool": {
"must": [
{"term": {"pictorial_id": pictorial_id}},
{"term": {"is_online": True}},
{"term": {"is_deleted": False}},
]
}
},
"sort":[
"sort": [
{"total_vote_num": {"order": "desc"}},
{"create_time": {"order": "desc"}}
]
}
pict_pictorial_ids_list =[]
pict_pictorial_ids_list = []
# 获取es链接对象
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"]
pict_pictorial_ids_list.append(topic_id)
return {"pict_pictorial_ids_list":pict_pictorial_ids_list}
return {"pict_pictorial_ids_list": pict_pictorial_ids_list}
except:
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