|  | @@ -61,12 +61,11 @@ def update_threshold(threshold_record_old, threshold_record_new):
 | 
	
		
			
				|  |  |              if threshold_old is None:
 | 
	
		
			
				|  |  |                  continue
 | 
	
		
			
				|  |  |              # 计算新的阈值
 | 
	
		
			
				|  |  | -            log_.info(f"{threshold_old}, {threshold_param_old}, {threshold_param_new}")
 | 
	
		
			
				|  |  |              threshold_new = float(threshold_old) / threshold_param_old * threshold_param_new
 | 
	
		
			
				|  |  |              log_.info(f"ad_abtest_tag = {ad_abtest_tag}, group_key = {group_key}, "
 | 
	
		
			
				|  |  |                        f"threshold_old = {threshold_old}, threshold_new = {threshold_new}")
 | 
	
		
			
				|  |  |              # 更新redis
 | 
	
		
			
				|  |  | -            # redis_helper.set_data_to_redis(key_name=key_name, value=threshold_new)
 | 
	
		
			
				|  |  | +            redis_helper.set_data_to_redis(key_name=key_name, value=threshold_new)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def update_ad_abtest_threshold(project, table, dt, ad_abtest_abcode_config):
 | 
	
	
		
			
				|  | @@ -81,13 +80,13 @@ def update_ad_abtest_threshold(project, table, dt, ad_abtest_abcode_config):
 | 
	
		
			
				|  |  |      # 根据活跃人数变化计算新的阈值参数
 | 
	
		
			
				|  |  |      threshold_record_new = get_threshold_record_new(ad_abtest_abcode_config=ad_abtest_abcode_config,
 | 
	
		
			
				|  |  |                                                      feature_df=feature_df, threshold_record=threshold_record)
 | 
	
		
			
				|  |  | -    log_.info(f"threshold_record = {threshold_record}")
 | 
	
		
			
				|  |  |      log_.info(f"threshold_record_new = {threshold_record_new}")
 | 
	
		
			
				|  |  |      # 更新阈值
 | 
	
		
			
				|  |  |      update_threshold(threshold_record_old=threshold_record, threshold_record_new=threshold_record_new)
 | 
	
		
			
				|  |  |      # 更新阈值参数
 | 
	
		
			
				|  |  | -    # redis_helper.set_data_to_redis(key_name=config_.KEY_NAME_PREFIX_AD_THRESHOLD_RECORD,
 | 
	
		
			
				|  |  | -    #                                value=str(threshold_record_new))
 | 
	
		
			
				|  |  | +    redis_helper.set_data_to_redis(key_name=config_.KEY_NAME_PREFIX_AD_THRESHOLD_RECORD,
 | 
	
		
			
				|  |  | +                                   value=str(threshold_record_new))
 | 
	
		
			
				|  |  | +    return threshold_record, threshold_record_new
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def timer_check():
 | 
	
	
		
			
				|  | @@ -105,16 +104,22 @@ def timer_check():
 | 
	
		
			
				|  |  |          if data_count > 0:
 | 
	
		
			
				|  |  |              log_.info(f"data count = {data_count}")
 | 
	
		
			
				|  |  |              # 数据准备好,进行更新
 | 
	
		
			
				|  |  | -            update_ad_abtest_threshold(project=project, table=table, dt=dt,
 | 
	
		
			
				|  |  | -                                       ad_abtest_abcode_config=ad_abtest_abcode_config)
 | 
	
		
			
				|  |  | +            threshold_record, threshold_record_new = update_ad_abtest_threshold(
 | 
	
		
			
				|  |  | +                project=project, table=table, dt=dt, ad_abtest_abcode_config=ad_abtest_abcode_config)
 | 
	
		
			
				|  |  | +            send_msg_to_feishu(
 | 
	
		
			
				|  |  | +                webhook=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('webhook'),
 | 
	
		
			
				|  |  | +                key_word=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('key_word'),
 | 
	
		
			
				|  |  | +                msg_text=f"rov-offline{config_.ENV_TEXT} - 阈值更新完成!\n"
 | 
	
		
			
				|  |  | +                         f"threshold_param_old: {threshold_record}\n"
 | 
	
		
			
				|  |  | +                         f"threshold_param_new: {threshold_record_new}\n"
 | 
	
		
			
				|  |  | +            )
 | 
	
		
			
				|  |  |              log_.info(f"threshold update end!")
 | 
	
		
			
				|  |  |          elif now_min > 45:
 | 
	
		
			
				|  |  |              log_.info('threshold update data is None!')
 | 
	
		
			
				|  |  |              send_msg_to_feishu(
 | 
	
		
			
				|  |  | -                webhook=config_.FEISHU_ROBOT['server_robot'].get('webhook'),
 | 
	
		
			
				|  |  | -                key_word=config_.FEISHU_ROBOT['server_robot'].get('key_word'),
 | 
	
		
			
				|  |  | +                webhook=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('webhook'),
 | 
	
		
			
				|  |  | +                key_word=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('key_word'),
 | 
	
		
			
				|  |  |                  msg_text=f"rov-offline{config_.ENV_TEXT} - 阈值更新相关数据未准备好!\n"
 | 
	
		
			
				|  |  | -                         f"traceback: {traceback.format_exc()}"
 | 
	
		
			
				|  |  |              )
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              # 数据没准备好,1分钟后重新检查
 | 
	
	
		
			
				|  | @@ -123,8 +128,8 @@ def timer_check():
 | 
	
		
			
				|  |  |      except Exception as e:
 | 
	
		
			
				|  |  |          log_.error(f"阈值更新失败, exception: {e}, traceback: {traceback.format_exc()}")
 | 
	
		
			
				|  |  |          send_msg_to_feishu(
 | 
	
		
			
				|  |  | -            webhook=config_.FEISHU_ROBOT['server_robot'].get('webhook'),
 | 
	
		
			
				|  |  | -            key_word=config_.FEISHU_ROBOT['server_robot'].get('key_word'),
 | 
	
		
			
				|  |  | +            webhook=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('webhook'),
 | 
	
		
			
				|  |  | +            key_word=config_.FEISHU_ROBOT['ad_threshold_auto_update_robot'].get('key_word'),
 | 
	
		
			
				|  |  |              msg_text=f"rov-offline{config_.ENV_TEXT} - 阈值更新失败\n"
 | 
	
		
			
				|  |  |                       f"exception: {e}\n"
 | 
	
		
			
				|  |  |                       f"traceback: {traceback.format_exc()}"
 | 
	
	
		
			
				|  | @@ -132,4 +137,4 @@ def timer_check():
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  if __name__ == '__main__':
 | 
	
		
			
				|  |  | -    timer_check()
 | 
	
		
			
				|  |  | +    timer_check()
 |