|
@@ -206,7 +206,8 @@ def add_videos(initial_df, now_date, rule_key, region, data_key, hour_count, top
|
|
|
return df
|
|
|
|
|
|
|
|
|
-def video_rank(df, now_date, now_h, rule_key, param, region, data_key, rule_rank_h_flag, add_videos_with_pre6h=False):
|
|
|
+def video_rank(df, now_date, now_h, rule_key, param, region, data_key, rule_rank_h_flag,
|
|
|
+ add_videos_with_pre_h=False, hour_count=0):
|
|
|
"""
|
|
|
获取符合进入召回源条件的视频,与每日更新的rov模型结果视频列表进行合并
|
|
|
:param df:
|
|
@@ -232,9 +233,9 @@ def video_rank(df, now_date, now_h, rule_key, param, region, data_key, rule_rank
|
|
|
h_recall_df['videoid'] = h_recall_df['videoid'].astype(int)
|
|
|
|
|
|
# 增加打捞的优质视频
|
|
|
- if add_videos_with_pre6h is True:
|
|
|
+ if add_videos_with_pre_h is True:
|
|
|
h_recall_df = add_videos(initial_df=h_recall_df, now_date=now_date, rule_key=rule_key,
|
|
|
- region=region, data_key=data_key, hour_count=6, top=10)
|
|
|
+ region=region, data_key=data_key, hour_count=hour_count, top=10)
|
|
|
|
|
|
h_recall_videos = h_recall_df['videoid'].to_list()
|
|
|
# log_.info(f'h_recall videos count = {len(h_recall_videos)}')
|
|
@@ -421,7 +422,7 @@ def merge_df_with_score(df_left, df_right):
|
|
|
|
|
|
|
|
|
def process_with_region(region, df_merged, data_key, rule_key, rule_param, now_date, now_h,
|
|
|
- rule_rank_h_flag, add_videos_with_pre6h):
|
|
|
+ rule_rank_h_flag, add_videos_with_pre_h, hour_count):
|
|
|
log_.info(f"region = {region} start...")
|
|
|
# 计算score
|
|
|
region_df = df_merged[df_merged['code'] == region]
|
|
@@ -429,18 +430,18 @@ def process_with_region(region, df_merged, data_key, rule_key, rule_param, now_d
|
|
|
score_df = cal_score(df=region_df, param=rule_param)
|
|
|
video_rank(df=score_df, now_date=now_date, now_h=now_h, rule_key=rule_key, param=rule_param,
|
|
|
region=region, data_key=data_key, rule_rank_h_flag=rule_rank_h_flag,
|
|
|
- add_videos_with_pre6h=add_videos_with_pre6h)
|
|
|
+ add_videos_with_pre_h=add_videos_with_pre_h, hour_count=hour_count)
|
|
|
log_.info(f"region = {region} end!")
|
|
|
|
|
|
|
|
|
def process_with_region2(region, df_merged, data_key, rule_key, rule_param, now_date, now_h,
|
|
|
- rule_rank_h_flag, add_videos_with_pre6h):
|
|
|
+ rule_rank_h_flag, add_videos_with_pre_h, hour_count):
|
|
|
log_.info(f"region = {region} start...")
|
|
|
region_score_df = df_merged[df_merged['code'] == region]
|
|
|
log_.info(f'region = {region}, region_score_df count = {len(region_score_df)}')
|
|
|
video_rank(df=region_score_df, now_date=now_date, now_h=now_h, region=region,
|
|
|
rule_key=rule_key, param=rule_param, data_key=data_key, rule_rank_h_flag=rule_rank_h_flag,
|
|
|
- add_videos_with_pre6h=add_videos_with_pre6h)
|
|
|
+ add_videos_with_pre_h=add_videos_with_pre_h, hour_count=hour_count)
|
|
|
log_.info(f"region = {region} end!")
|
|
|
|
|
|
|
|
@@ -537,7 +538,8 @@ def process_with_param(param, data_params_item, rule_params_item, region_code_li
|
|
|
log_.info(f"rule_key = {rule_key}, rule_param = {rule_param}")
|
|
|
merge_func = rule_param.get('merge_func', None)
|
|
|
# 是否在地域小时级数据中增加打捞的优质视频
|
|
|
- add_videos_with_pre6h = rule_param.get('add_videos_with_pre6h', False)
|
|
|
+ add_videos_with_pre_h = rule_param.get('add_videos_with_pre_h', False)
|
|
|
+ hour_count = rule_param.get('hour_count', 0)
|
|
|
|
|
|
if merge_func == 2:
|
|
|
score_df_list = []
|
|
@@ -554,7 +556,7 @@ def process_with_param(param, data_params_item, rule_params_item, region_code_li
|
|
|
task_list = [
|
|
|
gevent.spawn(process_with_region2,
|
|
|
region, df_merged, data_key, rule_key, rule_param, now_date, now_h, rule_rank_h_flag,
|
|
|
- add_videos_with_pre6h)
|
|
|
+ add_videos_with_pre_h, hour_count)
|
|
|
for region in region_code_list
|
|
|
]
|
|
|
else:
|
|
@@ -563,7 +565,7 @@ def process_with_param(param, data_params_item, rule_params_item, region_code_li
|
|
|
task_list = [
|
|
|
gevent.spawn(process_with_region,
|
|
|
region, df_merged, data_key, rule_key, rule_param, now_date, now_h, rule_rank_h_flag,
|
|
|
- add_videos_with_pre6h)
|
|
|
+ add_videos_with_pre_h, hour_count)
|
|
|
for region in region_code_list
|
|
|
]
|
|
|
|