فهرست منبع

change expire_time to weeek

yangxiaohui 1 سال پیش
والد
کامیت
330e6be8ac
2فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 5 3
      get_sample_ad_out_v1_item.py
  2. 5 3
      get_sample_ad_out_v1_user.py

+ 5 - 3
get_sample_ad_out_v1_item.py

@@ -126,7 +126,7 @@ mid AS u_id
 ,round(if(i_rov_3month > 10.0, 10.0, i_rov_3month) / 10.0, 6) as i_rov_3month
 ,round(if(i_ros_3month > 10.0, 10.0, i_ros_3month) / 10.0, 6) as i_ros_3month
 from
-user_video_features_data_final
+loghubods.user_video_features_data_final
 where dt='{datetime}'
 and ad_ornot = '0'
 and apptype != '13'
@@ -238,12 +238,14 @@ from candidate_item
     print(key_name_prefix)
     mean_item_h = 0.0
     count_item_h = 0
+    # 过期时间:一周
+    expire_time = 7 * 24 * 3600
     with data.open_reader() as reader:
         for row in tqdm(reader):
             k = str(row['i_id'])
             item_features = get_item_features(row)
             item_h = lr_model.predict_h(item_features)
-            redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", item_h, 28 * 3600)
+            redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", item_h, expire_time)
             item_h_dict[k] = item_h
             mean_item_h += item_h
             count_item_h += 1
@@ -254,7 +256,7 @@ from candidate_item
     print(mean_item_h)
     print(count_item_h)
     k = 'mean'
-    redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", mean_item_h, 28 * 3600)
+    redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", mean_item_h, expire_time)
     with open('{}.json'.format(key_name_prefix), 'w') as fout:
         json.dump(item_h_dict, fout, indent=2, ensure_ascii=False, sort_keys=True)
 

+ 5 - 3
get_sample_ad_out_v1_user.py

@@ -125,7 +125,7 @@ mid AS u_id
 ,round(if(i_rov_3month > 10.0, 10.0, i_rov_3month) / 10.0, 6) as i_rov_3month
 ,round(if(i_ros_3month > 10.0, 10.0, i_ros_3month) / 10.0, 6) as i_ros_3month
 from
-user_video_features_data_final
+loghubods.user_video_features_data_final
 where dt='{datetime}'
 and ad_ornot = '0'
 and apptype != '13'
@@ -237,12 +237,14 @@ from candidate_user
     print(key_name_prefix)
     mean_user_h = 0.0
     count_user_h = 0
+    # 过期时间:一周
+    expire_time = 7 * 24 * 3600
     with data.open_reader() as reader:
         for row in tqdm(reader):
             k = str(row['u_id'])
             user_features = get_user_features(row)
             user_h = lr_model.predict_h(user_features)
-            redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", user_h, 28 * 3600)
+            redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", user_h, expire_time)
             user_h_dict[k] = user_h
             mean_user_h += user_h
             count_user_h += 1
@@ -253,7 +255,7 @@ from candidate_user
     print(mean_user_h)
     print(count_user_h)
     k = 'mean'
-    redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", mean_user_h, 28 * 3600)
+    redis_helper.set_data_to_redis(f"{key_name_prefix}:{k}", mean_user_h, expire_time)
     with open('{}.json'.format(key_name_prefix), 'w') as fout:
         json.dump(user_h_dict, fout, indent=2, ensure_ascii=False, sort_keys=True)