Browse Source

add monitor task

luojunhui 2 days ago
parent
commit
9a514375d9

+ 1 - 0
applications/tasks/monitor_tasks/__init__.py

@@ -3,3 +3,4 @@ from .get_off_videos import GetOffVideos
 from .get_off_videos import CheckVideoAuditStatus
 from .gzh_article_monitor import OutsideGzhArticlesMonitor
 from .gzh_article_monitor import OutsideGzhArticlesCollector
+from .gzh_article_monitor import InnerGzhArticlesMonitor

+ 5 - 2
applications/tasks/monitor_tasks/gzh_article_monitor.py

@@ -218,7 +218,7 @@ class OutsideGzhArticlesMonitor(OutsideGzhArticlesManager):
 
     async def deal(self):
         article_list = await self.fetch_article_list_to_check()
-        for article in tqdm(article_list):
+        for article in tqdm(article_list, desc="外部服务号监控"):
             try:
                 await self.check_each_article(article)
 
@@ -301,6 +301,7 @@ class InnerGzhArticlesMonitor(MonitorConst):
                             "error_detail": error_detail,
                         },
                         mention=False,
+                        env="prod"
                     )
                     await delete_illegal_gzh_articles(gh_id, title)
 
@@ -309,5 +310,7 @@ class InnerGzhArticlesMonitor(MonitorConst):
 
     async def deal(self):
         article_list = await self.fetch_article_list_to_check()
-        for article in tqdm(article_list):
+        for article in tqdm(article_list, desc="站内文章监测任务"):
             await self.check_each_article(article)
+
+        return self.TASK_SUCCESS_CODE

+ 17 - 0
applications/tasks/task_scheduler.py

@@ -7,6 +7,7 @@ from applications.utils import task_schedule_response
 from applications.tasks.monitor_tasks import check_kimi_balance
 from applications.tasks.monitor_tasks import GetOffVideos
 from applications.tasks.monitor_tasks import CheckVideoAuditStatus
+from applications.tasks.monitor_tasks import InnerGzhArticlesMonitor
 from applications.tasks.monitor_tasks import OutsideGzhArticlesMonitor
 from applications.tasks.monitor_tasks import OutsideGzhArticlesCollector
 
@@ -178,6 +179,22 @@ class TaskScheduler:
                     },
                 )
 
+            case "inner_article_monitor":
+
+                async def background_inner_article_monitor():
+                    task = InnerGzhArticlesMonitor(self.db_client)
+                    final_status = await task.deal()
+                    await self.release_task(task_name, date_string, final_status=final_status)
+
+                asyncio.create_task(background_inner_article_monitor())
+                return await task_schedule_response.success_response(
+                    task_name=task_name,
+                    data={
+                        "code": 0,
+                        "message": "inner_article_monitor started background",
+                    }
+                )
+
             case _:
                 await self.log_client.log(
                     contents={