liqian 3 năm trước cách đây
mục cha
commit
7e2bc359f4
3 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 2 2
      utils.py
  2. 3 3
      video_rank.py
  3. 3 3
      video_recall.py

+ 2 - 2
utils.py

@@ -49,13 +49,13 @@ def get_videos_remain_view_count(app_type, videos):
 
 class FilterVideos(object):
     """视频过滤"""
-    def __init__(self, app_type, mid, uid, video_ids):
+    def __init__(self, app_type, video_ids, mid='', uid=''):
         """
         初始化
         :param app_type: 产品标识 type-int
+        :param video_ids: 需过滤的视频列表 type-list
         :param mid: mid type-string
         :param uid: uid type-string
-        :param video_ids: 需过滤的视频列表 type-list
         """
         self.app_type = app_type
         self.mid = mid

+ 3 - 3
video_rank.py

@@ -85,7 +85,7 @@ def remove_duplicate(rov_recall, flow_recall):
     return rov_recall, flow_recall
 
 
-def bottom_strategy(size, app_type, ab_code, mid='', uid=''):
+def bottom_strategy(size, app_type, ab_code):
     """
     兜底策略: 从ROV召回池中获取top1000,进行状态过滤后的视频
     :param size: 需要获取的视频数
@@ -95,7 +95,7 @@ def bottom_strategy(size, app_type, ab_code, mid='', uid=''):
     :param uid:
     :return:
     """
-    pool_recall = PoolRecall(app_type=app_type, mid=mid, uid=uid, ab_code=ab_code)
+    pool_recall = PoolRecall(app_type=app_type, ab_code=ab_code)
     key_name, _ = pool_recall.get_pool_redis_key(pool_type='rov')
     if not key_name:
         log_.info('bottom strategy no data!')
@@ -106,7 +106,7 @@ def bottom_strategy(size, app_type, ab_code, mid='', uid=''):
         log_.info('bottom strategy no data!')
         return []
     # 状态过滤
-    filter_videos = FilterVideos(app_type=app_type, mid=mid, uid=uid, video_ids=data)
+    filter_videos = FilterVideos(app_type=app_type, video_ids=data)
     filtered_data = filter_videos.filter_video_status(video_ids=data)
     random_data = numpy.random.choice(filtered_data, size, False)
     bottom_data = [{'videoId': item, 'pushFrom': 'bottom_strategy', 'abCode': ab_code} for item in random_data]

+ 3 - 3
video_recall.py

@@ -12,7 +12,7 @@ config_ = set_config()
 
 class PoolRecall(object):
     """召回"""
-    def __init__(self, app_type, mid, uid, ab_code):
+    def __init__(self, app_type, mid='', uid='', ab_code=''):
         """
         初始化
         :param app_type: 产品标识 type-int
@@ -175,8 +175,8 @@ class PoolRecall(object):
             else:
                 redis_date = (date.today() - timedelta(days=1)).strftime('%Y%m%d')
                 key_name = config_.RECALL_KEY_NAME_PREFIX + '{}.{}'.format(self.app_type, redis_date)
-                if not self.redis_helper.key_exists(key_name):
-                    return None, None
+                # if not self.redis_helper.key_exists(key_name):
+                #     return None, None
             return key_name, redis_date
 
         elif pool_type == 'flow':