Changed way of changing task's message

This commit is contained in:
Анатолий Богомолов 2024-02-08 18:00:37 +10:00
parent 81f97ee3d1
commit 557d19ea0d
2 changed files with 7 additions and 7 deletions

View File

@ -2,18 +2,18 @@ from app.extensions import db
from app.models.task import Task
def success_state(task_id):
task = Task.query.filter_by(task_id=task_id).one()
task = Task.query.get(task_id)
task.status = "SUCCESS"
task.status_message = "Задача выполнена успешно"
task.status_message = "задача выполнена успешно"
db.session.commit()
def failure_state(task_id, exception):
task = Task.query.filter_by(task_id=task_id).one()
task = Task.query.get(task_id)
task.status = "FAILURE"
task.status_message = f"Произошла ошибка: {str(exception)}"
task.status_message = f"произошла ошибка {str(exception)}"
db.session.commit()
@ -22,6 +22,6 @@ def run_state(task_id, task_record_id):
task.task_id = task_id
task.status = "RUNNING"
task.status_message = "Задача запущена"
task.status_message = "задача запущена"
db.session.commit()

View File

@ -31,11 +31,11 @@ def add_to_group_task(self, task_id):
)
except Exception as e:
failure_state(self.request.id, e)
failure_state(task_id, e)
raise e
else:
success_state(self.request.id)
success_state(task_id)