Commit f90e0b9e authored by lixiaofang's avatar lixiaofang

add

parent e10b33c3
...@@ -17,5 +17,6 @@ ...@@ -17,5 +17,6 @@
<element value="search.views.contrast_similar"/> <element value="search.views.contrast_similar"/>
<element value="injection.data_sync.tasks"/> <element value="injection.data_sync.tasks"/>
<element value="search.views.contrast_similar"/> <element value="search.views.contrast_similar"/>
<element value="search.views.search_hotword"/>
</config> </config>
</gm_rpcd_config> </gm_rpcd_config>
...@@ -33,36 +33,37 @@ def search_hotword(device_id=-1): ...@@ -33,36 +33,37 @@ def search_hotword(device_id=-1):
try: try:
all_tag_name_list = set() all_tag_name_list = set()
# 获取搜索推荐热词 # 获取搜索推荐热词
results_registr_tag = RegisterShowTag.objects.filter(is_deleted=False, is_online=1).count() results_registr_tag = RegisterShowTag.objects.filter(is_deleted=False, is_online=1).count()
results_tag = Tag.objects.filter(is_online=True, collection=1).count() results_tag = Tag.objects.filter(is_online=True, collection=1).count()
for i in range(0, 6): tag_id = random.sample(range(1, results_registr_tag), 1)
tag_id = random.randint(0, results_registr_tag) results_tag_chose = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True)
results_tag_chose = Tag.objects.filter(id=tag_id).values_list("name", flat=True) for i in results_tag_chose:
all_tag_name_list.add(results_tag_chose) all_tag_name_list.add(i)
logging.info("get all_tag_name_list01:%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)
linucb_recommend_tag_data = redis_client.get(tag_recommend_redis_key) linucb_recommend_tag_data = redis_client.get(tag_recommend_redis_key)
linucb_recommend_tag_list = json.loads(linucb_recommend_tag_data) if linucb_recommend_tag_data else [] linucb_recommend_tag_list = json.loads(linucb_recommend_tag_data) if linucb_recommend_tag_data else []
for item in linucb_recommend_tag_list: for item in linucb_recommend_tag_list:
all_tag_name_list.add(item) results_tag_recommend = Tag.objects.filter(id=item, is_online=True).values_list("name", flat=True)
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)}
logging.info("get all_tag_name_list02:%s" % all_tag_name_list) logging.info("get all_tag_name_list02:%s" % all_tag_name_list)
# 取不够数则取核心标签 # 取不够数则取核心标签
if len(all_tag_name_list) < 12: if len(all_tag_name_list) < 12:
for i in range(0, 12): for i in range(0, 12):
tag_id = random.randint(0, results_tag) tag_id = random.sample(range(1, results_tag), 12 - len(all_tag_name_list))
results_tag_hexin = Tag.objects.filter(id=tag_id).values_list("name", flat=True) results_tag_hexin = Tag.objects.filter(id__in=tag_id).values_list("name", flat=True)
if results_tag_hexin not in all_tag_name_list: if results_tag_hexin not in all_tag_name_list:
all_tag_name_list.add(results_tag_hexin) all_tag_name_list.add(results_tag_hexin[0])
if len(all_tag_name_list) >= 12: if len(all_tag_name_list) >= 12:
logging.info("get all_tag_name_list03:%s" % all_tag_name_list) return {"recommend_tag_name": list(all_tag_name_list)}
return {"recommend_name": all_tag_name_list}
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"recommend_name": []} return {"recommend_tag_name": []}
This diff is collapsed.
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