|
@@ -227,6 +227,50 @@ def bottom_strategy_last(size, app_type, ab_code, params):
|
|
|
return bottom_data
|
|
|
|
|
|
|
|
|
+def bottom_strategy2(size, app_type, mid, uid, ab_code, client_info, params):
|
|
|
+ """
|
|
|
+ 兜底策略: 从兜底视频中随机获取视频,进行过滤后的视频
|
|
|
+ :param size: 需要获取的视频数
|
|
|
+ :param app_type: 产品标识 type-int
|
|
|
+ :param mid: mid
|
|
|
+ :param uid: uid
|
|
|
+ :param ab_code: abCode
|
|
|
+ :param client_info: 地域信息
|
|
|
+ :param params:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ city_code_list = [code for _, code in config_.CITY_CODE.items()]
|
|
|
+
|
|
|
+ province_code = client_info.get('provinceCode', '-1')
|
|
|
+
|
|
|
+ city_code = client_info.get('cityCode', '-1')
|
|
|
+ if city_code in city_code_list:
|
|
|
+
|
|
|
+ region_code = city_code
|
|
|
+ else:
|
|
|
+ region_code = province_code
|
|
|
+ if region_code == '':
|
|
|
+ region_code = '-1'
|
|
|
+
|
|
|
+ redis_helper = RedisHelper(params=params)
|
|
|
+ bottom_data = redis_helper.get_data_from_set(key_name=config_.BOTTOM2_KEY_NAME)
|
|
|
+ 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
|
|
|
+ video_ids = [int(item) for item in random_data]
|
|
|
+
|
|
|
+ filter_ = FilterVideos(request_id=params.request_id, app_type=app_type, mid=mid, uid=uid, video_ids=video_ids)
|
|
|
+ filtered_data = filter_.filter_videos(pool_type='flow', region_code=region_code)
|
|
|
+ if filtered_data:
|
|
|
+ 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):
|
|
|
"""
|
|
|
视频宽高比实验(每组的前两个视频调整为横屏视频),根据视频宽高比信息对视频进行重排
|