Browse Source

全量过滤 增加链接时间

zhangbo 1 year ago
parent
commit
28a8c6b878
2 changed files with 8 additions and 4 deletions
  1. 4 0
      app.py
  2. 4 4
      utils.py

+ 4 - 0
app.py

@@ -133,6 +133,7 @@ def homepage_recommend():
             env_dict['hotSenceType'] = int(hotSenceType)
             env_dict['recomTraceId'] = recomTraceId
             env_dict['recomInterface'] = "homepage"
+            env_dict['cityCode'] = client_info.get('cityCode', '-1')
         except:
             env_dict['app_type'] = 4
             env_dict['pagesource'] = str(pagesource)
@@ -145,6 +146,7 @@ def homepage_recommend():
             env_dict['hotSenceType'] = int(hotSenceType)
             env_dict['recomTraceId'] = recomTraceId
             env_dict['recomInterface'] = "homepage"
+            env_dict['cityCode'] = client_info.get('cityCode', '-1')
             log_.error("feature error",env_dict)
         params = Params(request_id=request_id)
         # size默认为10
@@ -267,6 +269,7 @@ def relevant_recommend():
             env_dict['recomInterface'] = "relevant_recommend"
             env_dict['recomTraceId'] = recomTraceId
             env_dict['relevant_video_id'] = video_id
+            env_dict['cityCode'] = client_info.get('cityCode', '-1')
         except:
             env_dict['app_type'] = 4
             env_dict['pagesource'] = str(pagesource)
@@ -280,6 +283,7 @@ def relevant_recommend():
             env_dict['recomInterface'] = "relevant_recommend"
             env_dict['relevant_video_id'] = video_id
             env_dict['recomTraceId'] = recomTraceId
+            env_dict['cityCode'] = client_info.get('cityCode', '-1')
             log_.error("feature error", env_dict)
         params = Params(request_id=request_id)
         recommend_result = video_relevant_recommend(

+ 4 - 4
utils.py

@@ -536,12 +536,12 @@ class FilterVideos(object):
                         "uid": self.uid,
                         "types": list(types),
                         "videoIds": video_ids,
-                        "cityCode": region_code,
+                        "cityCode": self.env_dict["cityCode"]  if "cityCode" in self.env_dict else "-1",
                         "hotSenceType": self.env_dict["hotSenceType"]  if "hotSenceType" in self.env_dict else 0
                         }
         # print(request_data)
         # 调用http接口
-        result = request_post(request_url=config_.VIDEO_FILTER_URL, request_data=request_data, timeout=(3, 3))
+        result = request_post(request_url=config_.VIDEO_FILTER_URL, request_data=request_data, timeout=(0.2, 1))
 
         # print("result:", result)
         if result is None:
@@ -871,12 +871,12 @@ class FilterVideos(object):
                         "uid": self.uid,
                         "types": types,
                         "videoIds": video_ids,
-                        "cityCode": region_code,
+                        "cityCode": self.env_dict["cityCode"] if "cityCode" in self.env_dict else "-1",
                         "hotSenceType": self.env_dict["hotSenceType"]  if "hotSenceType" in self.env_dict else 0
                         }
         # print(request_data)
         # 调用http接口
-        result = request_post(request_url=config_.VIDEO_FILTER_URL, request_data=request_data, timeout=(3, 3))
+        result = request_post(request_url=config_.VIDEO_FILTER_URL, request_data=request_data, timeout=(0.2, 1))
 
         # print("result:", result)
         if result is None: