liqian hace 2 años
padre
commit
9d24c58bb7
Se han modificado 1 ficheros con 12 adiciones y 7 borrados
  1. 12 7
      video_rank.py

+ 12 - 7
video_rank.py

@@ -239,13 +239,18 @@ def bottom_strategy2(size, app_type, mid, ab_code, params):
     """
     redis_helper = RedisHelper(params=params)
     bottom_data = redis_helper.get_data_from_set(key_name=config_.BOTTOM2_KEY_NAME)
-    random_data = numpy.random.choice(bottom_data, size * 5, False)
-    # 视频过滤
-    filter_videos = FilterVideos(request_id=params.request_id, app_type=app_type, video_ids=random_data, mid=mid)
-    filtered_data = filter_videos.filter_videos()
-    bottom_data = [{'videoId': int(video_id), 'pushFrom': config_.PUSH_FROM['bottom2'], 'abCode': ab_code}
-                   for video_id in filtered_data[:size]]
-    return bottom_data
+    bottom_result = []
+    if len(bottom_data) > 0:
+        try:
+            random_data = numpy.random.choice(bottom_data, size * 5, False)
+        except Exception as e:
+            random_data = bottom_data
+        # 视频过滤
+        filter_videos = FilterVideos(request_id=params.request_id, app_type=app_type, video_ids=random_data, mid=mid)
+        filtered_data = filter_videos.filter_videos()
+        bottom_result = [{'videoId': int(video_id), 'pushFrom': config_.PUSH_FROM['bottom2'], 'abCode': ab_code}
+                         for video_id in filtered_data[:size]]
+    return bottom_result
 
 
 def video_rank_by_w_h_rate(videos):