perf: 优化账号推送

This commit is contained in:
ibuler
2023-02-20 23:50:33 +08:00
parent 37c54e976f
commit c9534bb9c4
9 changed files with 33 additions and 81 deletions

View File

@@ -4,17 +4,14 @@ from assets.tasks.common import generate_automation_execution_data
from common.const.choices import Trigger
def automation_execute_start(task_name, tp, task_snapshot=None):
def quickstart_automation_by_snapshot(task_name, tp, task_snapshot=None):
from accounts.models import AutomationExecution
data = generate_automation_execution_data(task_name, tp, task_snapshot)
while True:
try:
_id = data['id']
AutomationExecution.objects.get(id=_id)
data['id'] = str(uuid.uuid4())
except AutomationExecution.DoesNotExist:
break
pk = data['id']
if AutomationExecution.objects.exists(id=pk):
data['id'] = str(uuid.uuid4())
execution = AutomationExecution.objects.create(
trigger=Trigger.manual, **data
)