|
@@ -32,6 +32,8 @@ level_weight = {'1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1}
|
|
|
flow_pool_abtest_config = {'control_group': [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
|
|
'experimental_flow_set_level': [],
|
|
|
'experimental_flow_set_level_score': []}
|
|
|
+ad_arpu = 0
|
|
|
+ad_roi_param = 0
|
|
|
|
|
|
|
|
|
def update_flow_pool_config():
|
|
@@ -53,18 +55,30 @@ def update_flow_pool_config():
|
|
|
flow_pool_abtest_config = json.loads(flow_pool_abtest_config)
|
|
|
|
|
|
|
|
|
-def update_ad_predict_params():
|
|
|
+def update_ad_roi_predict_params():
|
|
|
"""
|
|
|
定时更新广告预测相关预设配置到内存变量中
|
|
|
- 1. level_weight: 流量池层级权重
|
|
|
- 2. flow_pool_abtest_config: 流量池ab实验配置
|
|
|
+ 1. arpu: 上一周期arpu值
|
|
|
+ 2. roi_param: 计算roi使用参数
|
|
|
:return: None
|
|
|
"""
|
|
|
+ redis_helper = RedisHelper()
|
|
|
+ global ad_arpu
|
|
|
+ ad_arpu_initial = redis_helper.get_data_from_redis(key_name=config_.KEY_NAME_AD_ARPU)
|
|
|
+ if ad_arpu_initial is not None:
|
|
|
+ ad_arpu = float(ad_arpu_initial)
|
|
|
+
|
|
|
+ global ad_roi_param
|
|
|
+ ad_roi_param_initial = redis_helper.get_data_from_redis(key_name=config_.KEY_NAME_AD_ROI_PARAM)
|
|
|
+ if ad_roi_param_initial is not None:
|
|
|
+ ad_roi_param = float(ad_roi_param_initial)
|
|
|
|
|
|
|
|
|
sched = BackgroundScheduler(daemon=True, timezone='Asia/Shanghai')
|
|
|
sched.add_job(func=update_flow_pool_config, trigger="interval", seconds=10*60)
|
|
|
+sched.add_job(func=update_ad_roi_predict_params, trigger="interval", seconds=10*60)
|
|
|
update_flow_pool_config()
|
|
|
+update_ad_roi_predict_params()
|
|
|
sched.start()
|
|
|
|
|
|
app = Flask(__name__)
|
|
@@ -460,8 +474,8 @@ def ad_roi_predict():
|
|
|
mid=mid,
|
|
|
video_id=video_id,
|
|
|
ads=ads,
|
|
|
- arpu=arpu,
|
|
|
- roi_param=roi_param)
|
|
|
+ arpu=ad_arpu,
|
|
|
+ roi_param=ad_roi_param)
|
|
|
if predict_result is None:
|
|
|
result = {'code': -1, 'message': 'fail'}
|
|
|
else:
|