Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): 自动创建修复单据优化 #8548 #8549

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,13 +81,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 @@ -230,12 +223,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 @@ -292,6 +287,12 @@ def get_expire_flow_tickets(expire_type):


# ----------------------------- 异步执行任务函数 ----------------------------------------
@shared_task
def _create_ticket(ticket_type, creator, bk_biz_id, remark, details) -> None:
ygcyao marked this conversation as resolved.
Show resolved Hide resolved
"""创建一个新单据"""
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
Loading