perf: 修改网关自动化任务 (#9335)

Co-authored-by: feng <1304903146@qq.com>
This commit is contained in:
fit2bot
2023-01-18 17:14:02 +08:00
committed by GitHub
parent 571e9b1878
commit c2a8acb73b
10 changed files with 85 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
#
import uuid
from assets.tasks.common import generate_data
from common.const.choices import Trigger
@@ -7,6 +8,14 @@ from common.const.choices import Trigger
def automation_execute_start(task_name, tp, child_snapshot=None):
from accounts.models import AutomationExecution
data = generate_data(task_name, tp, child_snapshot)
while True:
try:
_id = data['id']
AutomationExecution.objects.get(id=_id)
data['id'] = str(uuid.uuid4())
except AutomationExecution.DoesNotExist:
break
execution = AutomationExecution.objects.create(
trigger=Trigger.manual, **data
)