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

modify linUCB

parent 67673bce
......@@ -59,7 +59,7 @@ class CollectData(object):
if len(recommend_tag_list) > 0:
tag_recommend_redis_key = self.linucb_recommend_redis_prefix + str(device_id)
redis_client.set(tag_recommend_redis_key, recommend_tag_list)
redis_client.set(tag_recommend_redis_key, json.dumps(recommend_tag_list))
# Todo:设置过期时间,调研set是否支持
redis_client.expire(tag_recommend_redis_key, 7*24*60*60)
......
......@@ -93,7 +93,7 @@ class TopicUtils(object):
return []
@classmethod
def get_topic_tag_info(cls, offset, size, topic_id_list):
def get_topic_tag_info(cls, offset, size, topic_id_list,user_id):
try:
q = {
"query":{
......
......@@ -59,7 +59,11 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
redis_field_val_list = redis_client.hmget(redis_key,redis_field_list)
tag_recommend_redis_key = "physical:linucb:tag_recommend:device_id:" + str(device_id)
recommend_tag_list = redis_client.get(tag_recommend_redis_key) or []
recommend_tag_list = []
# tag_recommend_val = redis_client.get(tag_recommend_redis_key)
# if tag_recommend_val:
# recommend_tag_list = json.loads(tag_recommend_val)
recommend_topic_ids = []
have_read_topic_id_list = list()
......@@ -209,9 +213,9 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
"""
@bind("physical/search/query_tag_id_by_topic")
def query_tag_id_by_topic(offset=0,size=10,topic_id_list=[]):
def query_tag_id_by_topic(offset=0,size=10,topic_id_list=[],user_id=-1):
try:
return TopicUtils.get_topic_tag_info(offset,size,topic_id_list)
return TopicUtils.get_topic_tag_info(offset,size,topic_id_list,user_id)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {}
......
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