|
@@ -142,9 +142,13 @@ class PoolRecall(object):
|
|
|
# 取其中一个 flow_pool 作为召回结果
|
|
|
# 添加视频源参数 pushFrom, abCode
|
|
|
flow_pool_recall_result.append(
|
|
|
- {'videoId': item[0], 'flowPool': item[1], 'distributeCount': item[2],
|
|
|
+ {'videoId': item[0], 'flowPool': item[1],
|
|
|
'rovScore': video_score[item[0]], 'pushFrom': 'flow_pool', 'abCode': self.ab_code}
|
|
|
)
|
|
|
+ # flow_pool_recall_result.append(
|
|
|
+ # {'videoId': item[0], 'flowPool': item[1], 'distributeCount': item[2],
|
|
|
+ # 'rovScore': video_score[item[0]], 'pushFrom': 'flow_pool', 'abCode': self.ab_code}
|
|
|
+ # )
|
|
|
flow_pool_recall_videos.append(item[0])
|
|
|
et_check = time.time()
|
|
|
log_.info('check result: result = {}, execute time = {}ms'.format(
|
|
@@ -162,9 +166,27 @@ class PoolRecall(object):
|
|
|
"""
|
|
|
flow_pool_key = self.get_pool_redis_key('flow')
|
|
|
videos = []
|
|
|
+ check_result = []
|
|
|
for video_id in video_ids:
|
|
|
for flow_pool in flow_pool_mapping[video_id]:
|
|
|
- videos.append({'videoId': video_id, 'flowPool': flow_pool})
|
|
|
+ # 判断是否有本地分发记录
|
|
|
+ cur_count = get_videos_local_distribute_count(video_id=video_id, flow_pool=flow_pool)
|
|
|
+ # 无记录
|
|
|
+ if cur_count is None:
|
|
|
+ videos.append({'videoId': video_id, 'flowPool': flow_pool})
|
|
|
+ # 本地分发数 cur_count > 0
|
|
|
+ elif cur_count > 0:
|
|
|
+ check_result.append((video_id, flow_pool))
|
|
|
+ # 本地分发数 cur_count <= 0,从流量召回池移除
|
|
|
+ else:
|
|
|
+ value = '{}-{}'.format(video_id, flow_pool)
|
|
|
+ self.redis_helper.remove_value_from_zset(key_name=flow_pool_key, value=value)
|
|
|
+ # 本次视频都有本地记录
|
|
|
+ if len(video_ids) == 0:
|
|
|
+ error_flag = False
|
|
|
+ return check_result, error_flag
|
|
|
+
|
|
|
+ # 本地无记录视频,检查实时分发数
|
|
|
view_count_result, error_flag = get_videos_remain_view_count(app_type=self.app_type, videos=videos)
|
|
|
log_.info('error_flag = {}, view_count_result = {}'.format(error_flag, view_count_result))
|
|
|
|
|
@@ -175,19 +197,24 @@ class PoolRecall(object):
|
|
|
value = '{}-{}'.format(item['videoId'], item['flowPool'])
|
|
|
self.redis_helper.remove_value_from_zset(key_name=flow_pool_key, value=value)
|
|
|
|
|
|
- check_result = []
|
|
|
+ redis_helper = RedisHelper()
|
|
|
for item in view_count_result:
|
|
|
if item[2] > 0:
|
|
|
# viewCount > 0
|
|
|
- # 判断本地分发数
|
|
|
- cur_count = get_videos_local_distribute_count(video_id=item[0], flow_pool=item[1])
|
|
|
- # 无记录 或 cur_count > 0
|
|
|
- if cur_count is None or cur_count > 0:
|
|
|
- check_result.append(item)
|
|
|
- # cur_count <= 0,从流量召回池移除
|
|
|
- else:
|
|
|
- value = '{}-{}'.format(item[0], item[1])
|
|
|
- self.redis_helper.remove_value_from_zset(key_name=flow_pool_key, value=value)
|
|
|
+ check_result.append(item)
|
|
|
+ # 将分发数更新到本地记录
|
|
|
+ key_name = '{}{}.{}'.format(config_.LOCAL_DISTRIBUTE_COUNT_PREFIX, item[0], item[1])
|
|
|
+ redis_helper.incr_key(key_name=key_name, amount=int(item[2]), expire_time=5 * 60)
|
|
|
+
|
|
|
+ # # 判断本地分发数
|
|
|
+ # cur_count = get_videos_local_distribute_count(video_id=item[0], flow_pool=item[1])
|
|
|
+ # # 无记录 或 cur_count > 0
|
|
|
+ # if cur_count is None or cur_count > 0:
|
|
|
+ # check_result.append(item)
|
|
|
+ # # cur_count <= 0,从流量召回池移除
|
|
|
+ # else:
|
|
|
+ # value = '{}-{}'.format(item[0], item[1])
|
|
|
+ # self.redis_helper.remove_value_from_zset(key_name=flow_pool_key, value=value)
|
|
|
else:
|
|
|
# viewCount <= 0
|
|
|
# 从流量召回池移除
|