Commit 954ca95f authored by Kai's avatar Kai

bug fix

parent a946d1e9
......@@ -98,12 +98,25 @@ class CollectData(object):
tag_id_list = recommend_tag_list[0:100]
tag_topic_id_list = ESPerform.get_tag_topic_list(tag_id_list,have_read_topic_id_list)
topic_recommend_redis_key = self.linucb_recommend_topic_id_prefix + str(device_id)
if click_topic_tag_list:
if len(click_topic_tag_list)>0:
tag_topic_id_list = click_topic_tag_list + tag_topic_id_list
else:
redis_topic_data_dict = redis_client.hgetall(topic_recommend_redis_key)
redis_topic_list = list()
cursor = -1
if b"data" in redis_topic_data_dict:
redis_topic_list = json.loads(redis_topic_data_dict[b"data"]) if redis_topic_data_dict[b"data"] else []
cursor = redis_topic_data_dict[b"cursor"]
if cursor==0 and len(redis_topic_list)>0:
tag_topic_id_list = redis_topic_list[:2] + tag_topic_id_list
redis_data_dict = {
"data": json.dumps(tag_topic_id_list),
"cursor":0
}
redis_client.hmset(topic_recommend_redis_key,redis_data_dict)
return True
except:
......
......@@ -59,7 +59,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
redis_field_val_list = redis_client.hmget(redis_key, redis_field_list)
topic_recommend_redis_key = "physical:linucb:topic_recommend:device_id:" + str(device_id)
click_recommend_redis_key = "physical:click_recommend:device_id:" + str(device_id)
# click_recommend_redis_key = "physical:click_recommend:device_id:" + str(device_id)
# recommend_tag_dict = dict()
......@@ -77,20 +77,20 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
recommend_topic_list = recommend_topic_id_list[cursor:newcursor]
redis_client.hset(topic_recommend_redis_key,"cursor",newcursor)
click_recommend_topic_id_list = list()
click_recommend_topic_list = list()
click_recommend_topic_dict = redis_client.hgetall(click_recommend_redis_key)
if b"data" in click_recommend_topic_dict:
click_recommend_topic_id_list = json.loads(click_recommend_topic_dict[b"data"])
cursor = int(str(click_recommend_topic_dict[b"cursor"], encoding="utf-8"))
newcursor = cursor + 2
if newcursor < 4 and len(click_recommend_topic_id_list) ==2:
for i in range(0,2):
click_recommend_topic_list.append(click_recommend_topic_id_list[i])
redis_client.hset(click_recommend_redis_key, "cursor", newcursor)
combine_recommend_topic_list_tmp = click_recommend_topic_list.extend(recommend_topic_list)
combine_recommend_topic_list = combine_recommend_topic_list_tmp[0:5]
# click_recommend_topic_id_list = list()
# click_recommend_topic_list = list()
#
# click_recommend_topic_dict = redis_client.hgetall(click_recommend_redis_key)
# if b"data" in click_recommend_topic_dict:
# click_recommend_topic_id_list = json.loads(click_recommend_topic_dict[b"data"])
# cursor = int(str(click_recommend_topic_dict[b"cursor"], encoding="utf-8"))
# newcursor = cursor + 2
# if newcursor < 4 and len(click_recommend_topic_id_list) ==2:
# for i in range(0,2):
# click_recommend_topic_list.append(click_recommend_topic_id_list[i])
# redis_client.hset(click_recommend_redis_key, "cursor", newcursor)
# combine_recommend_topic_list_tmp = click_recommend_topic_list.extend(recommend_topic_list)
# combine_recommend_topic_list = combine_recommend_topic_list_tmp[0:5]
have_read_topic_id_list = list()
if redis_field_val_list[0]:
......@@ -109,11 +109,13 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
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 []
size = size-len(combine_recommend_topic_list)
if len(recommend_topic_list)>0:
size = size-len(recommend_topic_list)
have_read_topic_id_list.extend(recommend_topic_list)
topic_id_list = TopicUtils.get_recommend_topic_ids(user_id=user_id, tag_id=tag_id, offset=offset, size=size,
single_size=size,query=query, query_type=query_type,
filter_topic_id_list=have_read_topic_id_list,
recommend_tag_list=combine_recommend_topic_list,
recommend_tag_list=recommend_topic_list,
user_similar_score_list=user_similar_score_redis_list,index_type="topic",routing="4,5",attention_tag_list=attention_tag_list)
have_read_group_id_set = set()
have_read_user_id_set = set()
......@@ -155,11 +157,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# else:
# break
topic_id_list.extend(combine_recommend_topic_list)
topic_id_list.extend(recommend_topic_list)
# recommend_topic_list.extend(topic_id_list)
have_read_topic_id_list.extend(topic_id_list)
if len(have_read_topic_id_list) > 30000:
......
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