From d8dda8f50d2b36d695f07baaaa1a82bb705b466b Mon Sep 17 00:00:00 2001 From: ycggyao Date: Thu, 19 Dec 2024 08:47:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E8=87=AA=E5=8A=A8=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BF=AE=E5=A4=8D=E5=8D=95=E6=8D=AE=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20#8548?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/ticket/tasks/ticket_tasks.py | 27 +++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/dbm-ui/backend/ticket/tasks/ticket_tasks.py b/dbm-ui/backend/ticket/tasks/ticket_tasks.py index 4f45f0425a..b966cedaee 100644 --- a/dbm-ui/backend/ticket/tasks/ticket_tasks.py +++ b/dbm-ui/backend/ticket/tasks/ticket_tasks.py @@ -82,13 +82,6 @@ def retry_exclusive_inner_flow(cls) -> None: for flow in to_retry_flows: InnerFlow(flow_obj=flow).retry() - @classmethod - def _create_ticket(cls, ticket_type, creator, bk_biz_id, remark, details) -> None: - """创建一个新单据""" - Ticket.create_ticket( - ticket_type=ticket_type, creator=creator, bk_biz_id=bk_biz_id, remark=remark, details=details - ) - @classmethod def auto_create_data_repair_ticket(cls): """根据例行校验的结果自动创建修复单据""" @@ -231,12 +224,14 @@ def auto_create_data_repair_ticket(cls): ], } ticket_type = getattr(TicketType, f"{db_type.upper()}_DATA_REPAIR") - cls._create_ticket( - ticket_type=ticket_type, - creator=DEFAULT_SYSTEM_USER, - bk_biz_id=biz, - remark=_("集群存在数据不一致,自动创建的数据修复单据"), - details=ticket_details, + _create_ticket.apply_async( + kwargs={ + "ticket_type": ticket_type, + "creator": DEFAULT_SYSTEM_USER, + "bk_biz_id": biz, + "remark": _("集群存在数据不一致,自动创建的数据修复单据"), + "details": ticket_details, + } ) @classmethod @@ -293,6 +288,12 @@ def get_expire_flow_tickets(expire_type): # ----------------------------- 异步执行任务函数 ---------------------------------------- +@shared_task +def _create_ticket(ticket_type, creator, bk_biz_id, remark, details) -> None: + """创建一个新单据""" + Ticket.create_ticket(ticket_type=ticket_type, creator=creator, bk_biz_id=bk_biz_id, remark=remark, details=details) + + @shared_task def _apply_ticket_task(ticket_id: int, func_name: str, params: dict): """执行异步任务函数体"""