Browse Source

将审核天数提高到7天

luojunhui 6 months ago
parent
commit
1f802d6fc1
1 changed files with 24 additions and 3 deletions
  1. 24 3
      coldStartTasks/publish/publish_video_to_pq_for_audit.py

+ 24 - 3
coldStartTasks/publish/publish_video_to_pq_for_audit.py

@@ -2,6 +2,7 @@
 @author: luojunhui
 @author: luojunhui
 将抓取的视频发送至pq获取视频的审核结果
 将抓取的视频发送至pq获取视频的审核结果
 """
 """
+import time
 import traceback
 import traceback
 from typing import List, Dict
 from typing import List, Dict
 
 
@@ -30,11 +31,13 @@ class PublishVideosForAudit(object):
         获取视频的信息
         获取视频的信息
         :return:
         :return:
         """
         """
+        already_published_count = self.get_published_articles_today()
+        rest_count = const.MAX_VIDEO_NUM - already_published_count
         sql = f"""
         sql = f"""
             SELECT id, article_title, video_oss_path 
             SELECT id, article_title, video_oss_path 
             FROM publish_single_video_source 
             FROM publish_single_video_source 
             WHERE audit_status = {const.VIDEO_AUDIT_INIT_STATUS}
             WHERE audit_status = {const.VIDEO_AUDIT_INIT_STATUS}
-            LIMIT {const.MAX_VIDEO_NUM};
+            LIMIT {rest_count};
             """
             """
         response = self.db.select(sql, cursor_type=DictCursor)
         response = self.db.select(sql, cursor_type=DictCursor)
         return response
         return response
@@ -59,6 +62,20 @@ class PublishVideosForAudit(object):
         )
         )
         return affected_rows
         return affected_rows
 
 
+    def get_published_articles_today(self):
+        """
+        获取今天发布的视频数量总量
+        :return:
+        """
+        select_sql = f"""
+            SELECT COUNT(1) as total_count
+            FROM publish_single_video_source
+            WHERE audit_status != {const.VIDEO_AUDIT_INIT_STATUS}
+            AND DATE(FROM_UNIXTIME(audit_timestamp)) = CURDATE();
+        """
+        response = self.db.select(select_sql, cursor_type=DictCursor)
+        return response[0]['total_count']
+
     def publish_each_video(self, video_obj: Dict) -> None:
     def publish_each_video(self, video_obj: Dict) -> None:
         """
         """
         发布视频到pq
         发布视频到pq
@@ -75,12 +92,12 @@ class PublishVideosForAudit(object):
             video_id = response_json['data']['id']
             video_id = response_json['data']['id']
             update_sql = f"""
             update_sql = f"""
                 UPDATE publish_single_video_source
                 UPDATE publish_single_video_source
-                SET audit_status = %s, audit_video_id = %s
+                SET audit_status = %s, audit_video_id = %s, audit_timestamp = %s
                 WHERE id = %s;
                 WHERE id = %s;
             """
             """
             affected_rows = self.db.update(
             affected_rows = self.db.update(
                 sql=update_sql,
                 sql=update_sql,
-                params=(const.VIDEO_AUDIT_PROCESSING_STATUS, video_id, video_obj['id'])
+                params=(const.VIDEO_AUDIT_PROCESSING_STATUS, video_id, int(time.time()), video_obj['id'])
             )
             )
             if affected_rows:
             if affected_rows:
                 print("视频发布成功--{}".format(video_id))
                 print("视频发布成功--{}".format(video_id))
@@ -185,3 +202,7 @@ class PublishVideosForAudit(object):
                     }
                     }
                 )
                 )
 
 
+
+if __name__ == '__main__':
+    pub = PublishVideosForAudit()
+    pub.publish_job()