From d26fc1367da36b1bf058c7c637a3ef1e4f802024 Mon Sep 17 00:00:00 2001 From: huangbaichao Date: Mon, 6 May 2024 17:17:21 +0800 Subject: [PATCH] Refactor: Use TaskStatus enum for task status handling This commit changes the status 'not started' from being hard-coded to being maintained by the TaskStatus enum. This enhancement ensures consistency across the codebase and improves maintainability. --- api/apps/document_app.py | 3 ++- api/db/__init__.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/apps/document_app.py b/api/apps/document_app.py index 08af7b1cf3..3c7b156c80 100644 --- a/api/apps/document_app.py +++ b/api/apps/document_app.py @@ -367,7 +367,8 @@ def change_parser(): return get_data_error_result(retmsg="Not supported yet!") e = DocumentService.update_by_id(doc.id, - {"parser_id": req["parser_id"], "progress": 0, "progress_msg": "", "run": "0"}) + {"parser_id": req["parser_id"], "progress": 0, "progress_msg": "", + "run": TaskStatus.UNSTART.value}) if not e: return get_data_error_result(retmsg="Document not found!") if "parser_config" in req: diff --git a/api/db/__init__.py b/api/db/__init__.py index 3d76407a61..e1a9ff2d82 100644 --- a/api/db/__init__.py +++ b/api/db/__init__.py @@ -64,6 +64,7 @@ class ChatStyle(StrEnum): class TaskStatus(StrEnum): + UNSTART = "0" RUNNING = "1" CANCEL = "2" DONE = "3"