|
@@ -635,9 +635,10 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
|
|
|
if score_result and len(score_result) > 0 and len(score_result) == len(recall_list):
|
|
|
for i in range(len(score_result)):
|
|
|
recall_list[i]['sort_score'] = score_result[i][0]
|
|
|
- #print(score_result[i][0])
|
|
|
recall_list[i]['flag_call_service'] = 1
|
|
|
rov_recall_rank = sorted(recall_list, key=lambda k: k.get('sort_score', 0), reverse=True)
|
|
|
+ else:
|
|
|
+ rov_recall_rank = sup_rank(data, pre_str, recall_list, rov_recall_rank)
|
|
|
else:
|
|
|
redisObj = RedisHelper()
|
|
|
vidKeys = []
|
|
@@ -731,6 +732,35 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
|
|
|
i += 1
|
|
|
return rank_result[:size], flow_num
|
|
|
|
|
|
+
|
|
|
+# 排序服务兜底
|
|
|
+def sup_rank(data, pre_str, recall_list, rov_recall_rank):
|
|
|
+ redisObj = RedisHelper()
|
|
|
+ vidKeys = []
|
|
|
+ for recall_item in data['rov_pool_recall']:
|
|
|
+ if len(recall_item) <= 0:
|
|
|
+ continue
|
|
|
+ vid = recall_item.get("videoId", 0)
|
|
|
+ vidKeys.append(pre_str + str(vid))
|
|
|
+ recall_list.append(recall_item)
|
|
|
+ video_scores = redisObj.get_batch_key(vidKeys)
|
|
|
+ if video_scores and len(recall_list) > 0 and len(video_scores) == len(recall_list):
|
|
|
+ for i in range(len(video_scores)):
|
|
|
+ try:
|
|
|
+ if video_scores[i] is None:
|
|
|
+ recall_list[i]['sort_score'] = 0.0
|
|
|
+ else:
|
|
|
+ video_score_str = json.loads(video_scores[i])
|
|
|
+ recall_list[i]['flag_call_service'] = 0
|
|
|
+ recall_list[i]['sort_score'] = video_score_str[0]
|
|
|
+ except Exception:
|
|
|
+ recall_list[i]['sort_score'] = 0.0
|
|
|
+ rov_recall_rank = sorted(recall_list, key=lambda k: k.get('sort_score', 0), reverse=True)
|
|
|
+ else:
|
|
|
+ rov_recall_rank = recall_list
|
|
|
+ return rov_recall_rank
|
|
|
+
|
|
|
+
|
|
|
def video_sanke_rank(data, size, top_K, flow_pool_P, ab_Code='', exp_config=None):
|
|
|
"""
|
|
|
视频分发排序
|