Skip to content

Commit

Permalink
fix(backend): 自动创建修复单据优化 #8548
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcyao authored and iSecloud committed Dec 23, 2024
1 parent fd6d371 commit d8dda8f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions dbm-ui/backend/ticket/tasks/ticket_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""根据例行校验的结果自动创建修复单据"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""执行异步任务函数体"""
Expand Down

0 comments on commit d8dda8f

Please sign in to comment.