Commit 08f92bb5 authored by lixiaofang's avatar lixiaofang

定时任务

parent 6647a8a6
......@@ -15,6 +15,7 @@ from libs.es import ESPerform
from libs.cache import redis_client
from trans2es.models.face_user_contrast_similar import FaceUserContrastSimilar, UserSimilarScore
from linucb.utils.register_user_tag import RegisterUserTag
from trans2es.models.tag import RegisterShowTag, Tag
@shared_task
......@@ -106,3 +107,22 @@ def sync_user_similar_score():
redis_client.set(redis_key, json.dumps(item_list))
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
@shared_task
def get_tag_count():
try:
# 获取搜索推荐热词
results_registr_tag = RegisterShowTag.objects.filter(is_deleted=False, is_online=1).count()
# 获取符合条件的核心词
results_tag = Tag.objects.filter(is_online=True, collection=1).count()
redis_registr_tag = "physical:search_hotword:results_registr_tag"
redis_tag = "physical:search_hotword:results_tag"
redis_client.set(redis_registr_tag, str(results_registr_tag))
redis_client.set(redis_tag, str(results_tag))
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -4,6 +4,7 @@
from gm_rpcd.all import bind
import logging
import traceback
import random
import json
from libs.cache import redis_client
from libs.es import ESPerform
......@@ -12,7 +13,7 @@ from search.utils.common import GroupSortTypes
from libs.es import ESPerform
from trans2es.models.pictorial import PictorialTopics
from trans2es.models.tag import RegisterShowTag, Tag
import random
from libs.cache import redis_client
@bind("physical/search/search_hotword")
......@@ -32,14 +33,8 @@ def search_hotword(device_id=-1):
"""
try:
all_tag_name_list = set()
# 获取搜索推荐热词
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_registr_tag = 25
results_tag = 10189849
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:
......
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