Commit 2ff62ef8 authored by 段英荣's avatar 段英荣

modify

parent 3e97dfff
......@@ -62,3 +62,26 @@ def sync_face_similar_data_to_redis():
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
@shared_task
def sync_user_similar_score():
try:
results_items = UserSimilarScore.objects.filter(is_deleted=False).distinct().values("user_id").values_list(flat=True)
redis_key_prefix = "physical:user_similar_score:user_id:"
logging.info("duan add,begin sync user_similar_score!")
for user_id in results_items:
redis_key = redis_key_prefix + str(user_id)
similar_results_items = UserSimilarScore.objects.filter(is_deleted=False,user_id=user_id).order_by("-score")
item_list = list()
for item in similar_results_items:
contrast_user_id = item.contrast_user_id
score = item.score
item_list.append(
[contrast_user_id,score]
)
redis_client.set(redis_key, json.dumps(item_list))
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -146,7 +146,7 @@ class TopicUtils(object):
same_group_user_info_list = result_dict["hits"][0]["_source"]["same_group_user_id_list"]
same_group_id_list = [item["user_id"] for item in same_group_user_info_list]
same_group_id_list = same_group_id_list[:1000]
same_group_id_list = same_group_id_list[:100]
user_tag_list = result_dict["hits"][0]["_source"]["tag_list"]
......@@ -178,12 +178,13 @@ class TopicUtils(object):
]
if len(user_similar_score_list)>0:
for item in user_similar_score_list:
for item in user_similar_score_list[:100]:
score_item = 3 * 10*item[1]
functions_list.append(
{
"filter": {"bool": {
"should": {"term": {"user_id": item[0]}}}},
"weight": 3 * 10*item[1],
"weight": score_item,
}
)
......
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