2024-01-31 19:37:01 +10:00
|
|
|
from app.extensions import db
|
|
|
|
from app.models.task import Task
|
|
|
|
|
|
|
|
def success_state(task_id):
|
2024-02-08 18:00:37 +10:00
|
|
|
task = Task.query.get(task_id)
|
2024-01-31 19:37:01 +10:00
|
|
|
|
|
|
|
task.status = "SUCCESS"
|
2024-02-08 18:00:37 +10:00
|
|
|
task.status_message = "задача выполнена успешно"
|
2024-03-13 18:48:52 +10:00
|
|
|
|
|
|
|
db.session.commit()
|
2024-01-31 19:37:01 +10:00
|
|
|
|
|
|
|
def failure_state(task_id, exception):
|
2024-02-08 18:00:37 +10:00
|
|
|
task = Task.query.get(task_id)
|
2024-01-31 19:37:01 +10:00
|
|
|
|
|
|
|
task.status = "FAILURE"
|
2024-02-08 18:00:37 +10:00
|
|
|
task.status_message = f"произошла ошибка {str(exception)}"
|
2024-03-13 18:48:52 +10:00
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
|
2024-01-31 19:37:01 +10:00
|
|
|
def run_state(task_id, task_record_id):
|
|
|
|
task = Task.query.get(task_record_id)
|
|
|
|
|
|
|
|
task.task_id = task_id
|
|
|
|
task.status = "RUNNING"
|
2024-03-13 18:48:52 +10:00
|
|
|
task.status_message = "задача запущена"
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
|