From 557d19ea0dd4b281bc07f67e98d1250955cfcd51 Mon Sep 17 00:00:00 2001 From: winet Date: Thu, 8 Feb 2024 18:00:37 +1000 Subject: [PATCH] Changed way of changing task's message --- app/blueprints/api/tasks/handlers.py | 10 +++++----- app/blueprints/api/tasks/tasks.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/blueprints/api/tasks/handlers.py b/app/blueprints/api/tasks/handlers.py index d5d72fc..4243fa9 100644 --- a/app/blueprints/api/tasks/handlers.py +++ b/app/blueprints/api/tasks/handlers.py @@ -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() \ No newline at end of file diff --git a/app/blueprints/api/tasks/tasks.py b/app/blueprints/api/tasks/tasks.py index c4a3e5c..99526e0 100644 --- a/app/blueprints/api/tasks/tasks.py +++ b/app/blueprints/api/tasks/tasks.py @@ -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)