wangkun 2 năm trước cách đây
mục cha
commit
bd978be992

+ 15 - 7
suisuiniannianyingfuqi/suisuiniannianyingfuqi_main/demo.py

@@ -2,7 +2,9 @@
 # @Author: wangkun
 # @Author: wangkun
 # @Time: 2023/5/15
 # @Time: 2023/5/15
 import random
 import random
+import time
 
 
+from common.common import Common
 from common.scheduling_db import MysqlHelper
 from common.scheduling_db import MysqlHelper
 
 
 
 
@@ -26,6 +28,7 @@ class Demo:
             "play_cnt": 1000,
             "play_cnt": 1000,
             "share_cnt": 1000,
             "share_cnt": 1000,
             "duration": 55,
             "duration": 55,
+            "publish_time_stamp": 1683648000,  # 2023-05-10 00:00:00
             "video_url": "www.baidu.com"
             "video_url": "www.baidu.com"
         }
         }
         rule_dict = {"play_cnt": {"min": 0, "max": 0},
         rule_dict = {"play_cnt": {"min": 0, "max": 0},
@@ -38,7 +41,16 @@ class Demo:
                      "share_cnt": {"min": 0, "max": 0},
                      "share_cnt": {"min": 0, "max": 0},
                      "comment_cnt": {"min": 0, "max": 0},
                      "comment_cnt": {"min": 0, "max": 0},
                      "favorite_cnt": {"min": 0, "max": 0},
                      "favorite_cnt": {"min": 0, "max": 0},
-                     "period": {"min": 1, "max": 0}}
+                     # "period": {"min": 10, "max": 0},
+                     "publish_time": {"min": 1673734400000, "max": 0}
+                     }
+
+        # 格式化 video_dict:publish_time_stamp
+        if "publish_time_stamp" in video_dict.keys():
+            video_dict["publish_time"] = video_dict["publish_time_stamp"]*1000
+        # 格式化 video_dict:period
+        if "period" not in video_dict.keys() and "publish_time" in video_dict.keys():
+            video_dict["period"] = int((int(time.time()*1000)-video_dict["publish_time"])/(3600*24*1000))
         # 格式化 rule_dict 最大值取值为 0 的问题
         # 格式化 rule_dict 最大值取值为 0 的问题
         for rule_value in rule_dict.values():
         for rule_value in rule_dict.values():
             if rule_value["max"] == 0:
             if rule_value["max"] == 0:
@@ -52,17 +64,13 @@ class Demo:
             for rule_key, rule_value in rule_dict.items():
             for rule_key, rule_value in rule_dict.items():
                 if video_key == rule_key:
                 if video_key == rule_key:
                     result = rule_value["min"] <= video_value <= rule_value["max"]
                     result = rule_value["min"] <= video_value <= rule_value["max"]
-                    print(f'{type(video_key)}: {type(rule_value["min"])} <= {type(video_value)} <= {type(rule_value["max"])}')
-                    print(f'{video_key}: {rule_value["min"]} <= {video_value} <= {rule_value["max"]}')
-                    print(f"result:{type(result)}, {result}")
-                    print("=========================\n")
+                    print(f'{video_key}: {rule_value["min"]} <= {video_value} <= {rule_value["max"]},{result}')
+                    # Common.logger(log_type, crawler).info(f'{video_key}: {rule_value["min"]} <= {video_value} <= {rule_value["max"]},{result}')
 
 
                     if result is False:
                     if result is False:
                         return False
                         return False
                     else:
                     else:
                         continue
                         continue
-
-
         return True
         return True
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":