Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud committed Oct 14, 2024
1 parent aecd7e8 commit 6fd2ad1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions dbm-ui/backend/ticket/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import itertools
import json
import logging
import time
from typing import Dict, List

from django.db import transaction
Expand All @@ -29,9 +30,11 @@
from backend.ticket.constants import (
FLOW_FINISHED_STATUS,
ITSM_FIELD_NAME__ITSM_KEY,
RUNNING_FLOW__TICKET_STATUS,
FlowTypeConfig,
OperateNodeActionType,
TicketFlowStatus,
TicketStatus,
TicketType,
)
from backend.ticket.exceptions import TicketFlowsConfigException
Expand Down Expand Up @@ -416,3 +419,20 @@ def query_ticket_flows_describe(cls, bk_biz_id, db_type, ticket_types=None):
flow_desc_list.append(flow_config_info)

return flow_desc_list

@classmethod
def ticket_status_standardization(cls):
"""
旧单据状态标准化。TODO: 迁移后此段代码可删除
"""
# 标准化只针对running的单据,其他状态单据不影响
running_tickets = Ticket.objects.filter(status=TicketStatus.RUNNING)
batch = 50

for current in range(0, running_tickets.count(), batch):
for ticket in running_tickets[current : current + batch]:
raw_status = ticket.status
ticket.status = RUNNING_FLOW__TICKET_STATUS[ticket.current_flow().flow_type]
ticket.save()
print(f"ticket[{ticket.id}] status {raw_status} ---> {ticket.status}")
time.sleep(1)

0 comments on commit 6fd2ad1

Please sign in to comment.