Commit 689e886e authored by lixiaofang's avatar lixiaofang

add

parent 5221e72e
......@@ -35,10 +35,14 @@ def search_hotword(device_id=-1):
all_tag_name_list = set()
results_registr_tag = int(redis_client.get("physical:search_hotword:results_registr_tag"))
results_tag = int(redis_client.get("physical:search_hotword:results_tag"))
tag_id = random.sample(range(1, results_registr_tag), 6)
results_tag_chose = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True)
for i in results_tag_chose:
all_tag_name_list.add(i)
# 先获取搜索推荐热词
for num in range(1, results_tag):
tag_id = random.randint(1, results_tag)
results_tag_chose = RegisterShowTag.objects.filter(id=tag_id, is_online=True).values_list("name",
flat=True)
all_tag_name_list.add(results_tag_chose)
if len(all_tag_name_list) == 6 or num == results_tag:
break
# 获取个性化标签
linucb_recommend_redis_prefix = "physical:linucb:tag_recommend:device_id:"
......@@ -50,11 +54,13 @@ def search_hotword(device_id=-1):
all_tag_name_list.add(results_tag_recommend[0])
if len(all_tag_name_list) == 12:
return {"recommend_tag_name": list(all_tag_name_list)}
# 取不够数则取核心标签
if len(all_tag_name_list) < 12:
for i in range(0, 12):
tag_id = random.sample(range(1, results_tag), 12 - len(all_tag_name_list))
results_tag_hexin = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True)
tag_id = random.randint(1, results_registr_tag)
results_tag_hexin = Tag.objects.filter(id=tag_id, is_online=True, collection=1).values_list("name",
flat=True)
if results_tag_hexin not in all_tag_name_list:
all_tag_name_list.add(results_tag_hexin[0])
if len(all_tag_name_list) >= 12:
......
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