Commit fbab248e authored by lixiaofang's avatar lixiaofang

判断是否有值

parent 74457fd7
...@@ -51,6 +51,7 @@ def search_hotword(device_id=-1): ...@@ -51,6 +51,7 @@ def search_hotword(device_id=-1):
if len(all_tag_name_list) == 6 or num == results_tag: if len(all_tag_name_list) == 6 or num == results_tag:
break break
logging.info("get all_tag_name_list:%s" % all_tag_name_list)
# 获取个性化标签 # 获取个性化标签
linucb_recommend_redis_prefix = "physical:linucb:tag_recommend:device_id:" linucb_recommend_redis_prefix = "physical:linucb:tag_recommend:device_id:"
tag_recommend_redis_key = linucb_recommend_redis_prefix + str(device_id) tag_recommend_redis_key = linucb_recommend_redis_prefix + str(device_id)
...@@ -59,7 +60,9 @@ def search_hotword(device_id=-1): ...@@ -59,7 +60,9 @@ def search_hotword(device_id=-1):
for item in linucb_recommend_tag_list: for item in linucb_recommend_tag_list:
results_tag_recommend = list( results_tag_recommend = list(
set(Tag.objects.filter(id=item, is_online=True).values_list("name", flat=True))) set(Tag.objects.filter(id=item, is_online=True).values_list("name", flat=True)))
all_tag_name_list.add(results_tag_recommend[0]) if results_tag_recommend:
all_tag_name_list.add(results_tag_recommend[0])
logging.info("get all_tag_name_list:%s" % all_tag_name_list)
if len(all_tag_name_list) == 12: if len(all_tag_name_list) == 12:
return {"recommend_tag_name": list(all_tag_name_list)} return {"recommend_tag_name": list(all_tag_name_list)}
...@@ -73,6 +76,8 @@ def search_hotword(device_id=-1): ...@@ -73,6 +76,8 @@ def search_hotword(device_id=-1):
if results_tag_hexin: if results_tag_hexin:
if results_tag_hexin[0] not in all_tag_name_list: if results_tag_hexin[0] not in all_tag_name_list:
all_tag_name_list.add(results_tag_hexin[0]) all_tag_name_list.add(results_tag_hexin[0])
logging.info("get all_tag_name_list:%s" % all_tag_name_list)
if len(all_tag_name_list) >= 12: if len(all_tag_name_list) >= 12:
return {"recommend_tag_name": list(all_tag_name_list)} return {"recommend_tag_name": list(all_tag_name_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