Commit 785ce448 authored by Kai's avatar Kai

update

parent 1550755f
...@@ -430,7 +430,11 @@ class ESPerform(object): ...@@ -430,7 +430,11 @@ class ESPerform(object):
topic_id_list = [item["_source"]["id"] for item in result_dict["hits"]] topic_id_list = [item["_source"]["id"] for item in result_dict["hits"]]
# logging.info("topic_id_list:%s" % str(topic_id_list)) # logging.info("topic_id_list:%s" % str(topic_id_list))
topic_id_dict = [{str(item["_source"]["id"]):item["_source"]["user_id"]} for item in result_dict["hits"]] # topic_id_dict = [{str(item["_source"]["id"]):item["_source"]["user_id"]} for item in result_dict["hits"]]
topic_id_dict = dict()
for item in result_dict["hits"]:
topic_id_dict[str(item["_source"]["id"])] = item["_source"]["user_id"]
logging.info("topic_id_list:%s" % str(topic_id_dict)) logging.info("topic_id_list:%s" % str(topic_id_dict))
return topic_id_list,topic_id_dict return topic_id_list,topic_id_dict
......
...@@ -74,9 +74,9 @@ class CollectData(object): ...@@ -74,9 +74,9 @@ class CollectData(object):
have_read_topic_id_list.extend(promote_recommend_topic_id_list) have_read_topic_id_list.extend(promote_recommend_topic_id_list)
recommend_topic_id_list = list() recommend_topic_id_list = list()
recommend_topic_id_list_dict = list() recommend_topic_id_list_dict = dict()
recommend_topic_id_list_click = list() recommend_topic_id_list_click = list()
recommend_topic_id_list_click_dict = list() recommend_topic_id_list_click_dict = dict()
if click_topic_tag_list: if click_topic_tag_list:
...@@ -85,7 +85,7 @@ class CollectData(object): ...@@ -85,7 +85,7 @@ class CollectData(object):
have_read_topic_id_list,size=2) have_read_topic_id_list,size=2)
if len(recommend_topic_id_list_click) > 0: if len(recommend_topic_id_list_click) > 0:
recommend_topic_id_list.extend(recommend_topic_id_list_click) recommend_topic_id_list.extend(recommend_topic_id_list_click)
recommend_topic_id_list_dict.extend(recommend_topic_id_list_click_dict) recommend_topic_id_list_dict.update(recommend_topic_id_list_click_dict)
have_read_topic_id_list.extend(recommend_topic_id_list_click) have_read_topic_id_list.extend(recommend_topic_id_list_click)
click_recommend_redis_key = self.click_recommend_redis_key_prefix + str(device_id) click_recommend_redis_key = self.click_recommend_redis_key_prefix + str(device_id)
click_redis_data_dict = { click_redis_data_dict = {
...@@ -109,7 +109,7 @@ class CollectData(object): ...@@ -109,7 +109,7 @@ class CollectData(object):
if len(recommend_topic_id_list)==0 and cursor==0 and len(redis_topic_list)>0: if len(recommend_topic_id_list)==0 and cursor==0 and len(redis_topic_list)>0:
have_read_topic_id_list.extend(redis_topic_list[:2]) have_read_topic_id_list.extend(redis_topic_list[:2])
tag_topic_dict = list() tag_topic_dict = dict()
if len(new_user_click_tag_list)>0: if len(new_user_click_tag_list)>0:
tag_topic_id_list,tag_topic_dict = ESPerform.get_tag_topic_list_dict(new_user_click_tag_list, have_read_topic_id_list) tag_topic_id_list,tag_topic_dict = ESPerform.get_tag_topic_list_dict(new_user_click_tag_list, have_read_topic_id_list)
...@@ -119,7 +119,7 @@ class CollectData(object): ...@@ -119,7 +119,7 @@ class CollectData(object):
if len(recommend_topic_id_list)>0 or len(new_user_click_tag_list) > 0: if len(recommend_topic_id_list)>0 or len(new_user_click_tag_list) > 0:
tag_topic_id_list = recommend_topic_id_list + tag_topic_id_list tag_topic_id_list = recommend_topic_id_list + tag_topic_id_list
tag_topic_dict = recommend_topic_id_list_dict + tag_topic_dict tag_topic_dict = recommend_topic_id_list_dict.update(tag_topic_dict)
redis_data_dict = { redis_data_dict = {
"data": json.dumps(tag_topic_id_list), "data": json.dumps(tag_topic_id_list),
"datadict":json.dumps(tag_topic_dict), "datadict":json.dumps(tag_topic_dict),
...@@ -128,7 +128,8 @@ class CollectData(object): ...@@ -128,7 +128,8 @@ class CollectData(object):
redis_client.hmset(topic_recommend_redis_key,redis_data_dict) redis_client.hmset(topic_recommend_redis_key,redis_data_dict)
else: else:
if cursor<=0 and len(redis_topic_list)>0: if cursor<=0 and len(redis_topic_list)>0:
tag_topic_dict = redis_topic_list[:2] + tag_topic_dict tag_topic_dict = list()
tag_topic_dict = redis_topic_list[:2]
tag_topic_dict = list(set(tag_topic_dict)) tag_topic_dict = list(set(tag_topic_dict))
return True return True
......
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