luojunhui 2 месяцев назад
Родитель
Сommit
1d22847498

+ 1 - 1
applications/tasks/data_recycle_tasks/recycle_daily_publish_articles.py

@@ -45,7 +45,7 @@ class Const:
         "gh_a2901d34f75b",
         "gh_5ae65db96cb7",
         "gh_72bace6b3059",
-        "gh_dd4c857bbb36"
+        "gh_dd4c857bbb36",
     ]
 
     # NOT USED SERVER ACCOUNT

+ 42 - 15
applications/tasks/monitor_tasks/auto_reply_cards_monitor.py

@@ -211,9 +211,7 @@ class AutoReplyCardsMonitorMapper(AutoReplyCardsMonitorUtils):
             FROM cooperate_accounts
             WHERE account_name = %s;
         """
-        return await self.pool.async_fetch(
-            query=query, params=(account_name,)
-        )
+        return await self.pool.async_fetch(query=query, params=(account_name,))
 
     # 更新账号状态为无效
     async def set_account_as_invalid(self, gh_id):
@@ -228,7 +226,11 @@ class AutoReplyCardsMonitorMapper(AutoReplyCardsMonitorUtils):
         query = """
             INSERT INTO gzh_msg_record (task_id, biz_type, task_params, create_timestamp, update_timestamp) VALUES (%s, %s, %s, %s, %s); 
         """
-        return await self.pool.async_save(query=query, params=(task_id, "follow", link, timestamp, timestamp), db_name="aigc")
+        return await self.pool.async_save(
+            query=query,
+            params=(task_id, "follow", link, timestamp, timestamp),
+            db_name="aigc",
+        )
 
     # 插入AIGC自动回复任务
     async def insert_aigc_auto_reply_task(self, task_id, account_name):
@@ -236,7 +238,11 @@ class AutoReplyCardsMonitorMapper(AutoReplyCardsMonitorUtils):
         query = """
             INSERT INTO gzh_msg_record (task_id, task_params, create_timestamp, update_timestamp) VALUES (%s, %s, %s, %s); 
         """
-        return await self.pool.async_save(query=query, params=(task_id,  account_name, timestamp, timestamp), db_name="aigc")
+        return await self.pool.async_save(
+            query=query,
+            params=(task_id, account_name, timestamp, timestamp),
+            db_name="aigc",
+        )
 
     # 为账号设置 sample_url
     async def set_sample_url(self, gh_id, sample_url):
@@ -250,7 +256,9 @@ class AutoReplyCardsMonitorMapper(AutoReplyCardsMonitorUtils):
         query = """
             UPDATE cooperate_accounts SET follow_status = %s WHERE gh_id = %s and follow_status = %s;
         """
-        return await self.pool.async_save(query=query, params=(new_status, gh_id, ori_status))
+        return await self.pool.async_save(
+            query=query, params=(new_status, gh_id, ori_status)
+        )
 
     # 从 aigc 获取关注结果
     async def fetch_follow_account_status(self, gh_id):
@@ -274,17 +282,21 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorMapper):
         code = response.get("code")
         match code:
             case 0:
-                recent_articles = response['data']['data'][0]['AppMsg']['DetailInfo']
+                recent_articles = response["data"]["data"][0]["AppMsg"]["DetailInfo"]
                 article_url = await self.get_sample_url(recent_articles)
                 print(article_url)
                 if article_url:
                     await self.set_sample_url(gh_id, article_url)
 
                     task_id = self.generate_task_id(task_name="follow", gh_id=gh_id)
-                    affected_rows = await self.insert_aigc_follow_account_task(task_id, article_url)
+                    affected_rows = await self.insert_aigc_follow_account_task(
+                        task_id, article_url
+                    )
 
                     if affected_rows:
-                        await self.update_follow_status(gh_id, self.INIT_STATUS, self.PROCESSING_STATUS)
+                        await self.update_follow_status(
+                            gh_id, self.INIT_STATUS, self.PROCESSING_STATUS
+                        )
 
             case 25013:
                 await self.set_account_as_invalid(gh_id)
@@ -314,12 +326,20 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorMapper):
 
                     match follow_status:
                         case self.INIT_STATUS:
-                            await self.create_follow_account_task(account_detail["gh_id"])
+                            await self.create_follow_account_task(
+                                account_detail["gh_id"]
+                            )
 
                         case self.PROCESSING_STATUS:
-                            fetch_response = await self.fetch_follow_account_status(account_detail["gh_id"])
+                            fetch_response = await self.fetch_follow_account_status(
+                                account_detail["gh_id"]
+                            )
                             if not fetch_response:
-                                await self.update_follow_status(account_detail["gh_id"], self.PROCESSING_STATUS, self.INIT_STATUS)
+                                await self.update_follow_status(
+                                    account_detail["gh_id"],
+                                    self.PROCESSING_STATUS,
+                                    self.INIT_STATUS,
+                                )
 
                             task_status = fetch_response[0]["task_status"]
                             match task_status:
@@ -328,9 +348,17 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorMapper):
                                 case self.FETCH_PROCESSING_STATUS:
                                     continue
                                 case self.FETCH_SUCCESS_STATUS:
-                                    await self.update_follow_status(account_detail["gh_id"], self.PROCESSING_STATUS, self.SUCCESS_STATUS)
+                                    await self.update_follow_status(
+                                        account_detail["gh_id"],
+                                        self.PROCESSING_STATUS,
+                                        self.SUCCESS_STATUS,
+                                    )
                                 case self.FETCH_FAIL_STATUS:
-                                    await self.update_follow_status(account_detail["gh_id"], self.PROCESSING_STATUS, self.FAIL_STATUS)
+                                    await self.update_follow_status(
+                                        account_detail["gh_id"],
+                                        self.PROCESSING_STATUS,
+                                        self.FAIL_STATUS,
+                                    )
 
                         case self.SUCCESS_STATUS:
                             continue
@@ -341,7 +369,6 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorMapper):
             except Exception as e:
                 print(f"处理账号{account.公众号名}异常", e)
 
-
     # main function
     async def deal(self, task_name):
         match task_name: