|
|
@@ -2,17 +2,16 @@ import traceback
|
|
|
|
|
|
from app.core.database import DatabaseManager
|
|
|
from app.core.observability import LogService
|
|
|
-from app.infra.external import feishu_robot
|
|
|
|
|
|
-from ._const import AdPlatformArticleColdStartConst
|
|
|
-from ._utils import AdPlatformArticleColdStartUtils
|
|
|
-from ._mapper import AdPlatformArticleColdStartMapper
|
|
|
+from ._const import AdPlatformArticlePublishConst
|
|
|
+from ._utils import AdPlatformArticlePublishUtils
|
|
|
+from ._mapper import AdPlatformArticlePublishMapper
|
|
|
|
|
|
|
|
|
-class AdPlatformArticleColdStartTask(AdPlatformArticleColdStartConst):
|
|
|
+class AdPlatformArticlePublishTask(AdPlatformArticlePublishConst):
|
|
|
def __init__(self, pool: DatabaseManager, log_service: LogService):
|
|
|
- self.mapper = AdPlatformArticleColdStartMapper(pool)
|
|
|
- self.tool = AdPlatformArticleColdStartUtils()
|
|
|
+ self.mapper = AdPlatformArticlePublishMapper(pool)
|
|
|
+ self.tool = AdPlatformArticlePublishUtils()
|
|
|
self.log_service = log_service
|
|
|
|
|
|
async def _process_single_plan(self, plan: str):
|
|
|
@@ -40,7 +39,6 @@ class AdPlatformArticleColdStartTask(AdPlatformArticleColdStartConst):
|
|
|
plan_response = await self.tool.create_crawler_plan(
|
|
|
category=category, article_list=candidate_articles
|
|
|
)
|
|
|
- print(plan_response)
|
|
|
|
|
|
# save to db
|
|
|
plan_info = self.tool.process_plan_info(plan_response)
|
|
|
@@ -76,7 +74,7 @@ class AdPlatformArticleColdStartTask(AdPlatformArticleColdStartConst):
|
|
|
await self.log_service.log(
|
|
|
contents={
|
|
|
"task": "ad_platform_article_cold_start",
|
|
|
- "status": "error",
|
|
|
+ "status": "fail",
|
|
|
"message": "回滚冷启状态失败",
|
|
|
"rollback_error": str(rollback_err),
|
|
|
}
|
|
|
@@ -84,22 +82,21 @@ class AdPlatformArticleColdStartTask(AdPlatformArticleColdStartConst):
|
|
|
await self.log_service.log(
|
|
|
contents={
|
|
|
"task": "ad_platform_article_cold_start",
|
|
|
- "status": "error",
|
|
|
+ "status": "fail",
|
|
|
"plan": plan,
|
|
|
"category": category,
|
|
|
"error": str(e),
|
|
|
"traceback": traceback.format_exc(),
|
|
|
}
|
|
|
)
|
|
|
- await feishu_robot.bot(
|
|
|
- title="互选平台文章冷启动任务异常",
|
|
|
+ await self.tool.alert(
|
|
|
+ title="冷启动任务异常",
|
|
|
detail={
|
|
|
"plan": plan,
|
|
|
"category": category,
|
|
|
"error": str(e),
|
|
|
"traceback": traceback.format_exc(),
|
|
|
},
|
|
|
- mention=False,
|
|
|
)
|
|
|
|
|
|
async def deal(self):
|
|
|
@@ -107,25 +104,25 @@ class AdPlatformArticleColdStartTask(AdPlatformArticleColdStartConst):
|
|
|
try:
|
|
|
for plan in self.PLAN_LIST:
|
|
|
await self._process_single_plan(plan)
|
|
|
+
|
|
|
except Exception as e:
|
|
|
await self.log_service.log(
|
|
|
contents={
|
|
|
"task": "ad_platform_article_cold_start",
|
|
|
- "status": "error",
|
|
|
+ "status": "fail",
|
|
|
"message": "deal 入口异常",
|
|
|
"error": str(e),
|
|
|
"traceback": traceback.format_exc(),
|
|
|
}
|
|
|
)
|
|
|
- await feishu_robot.bot(
|
|
|
+ await self.tool.alert(
|
|
|
title="互选平台文章冷启动任务-入口异常",
|
|
|
detail={
|
|
|
"error": str(e),
|
|
|
"traceback": traceback.format_exc(),
|
|
|
},
|
|
|
- mention=False,
|
|
|
)
|
|
|
raise
|
|
|
|
|
|
|
|
|
-__all__ = ["AdPlatformArticleColdStartTask"]
|
|
|
+__all__ = ["AdPlatformArticlePublishTask"]
|