Moonlit commited on
Commit
4a90706
·
1 Parent(s): 182a723

Refactor: Use TaskStatus enum for task status handling (#646)

Browse files

### What problem does this PR solve?

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.

### Type of change

- [x] Refactoring

Files changed (2) hide show
  1. api/apps/document_app.py +2 -1
  2. api/db/__init__.py +1 -0
api/apps/document_app.py CHANGED
@@ -367,7 +367,8 @@ def change_parser():
367
  return get_data_error_result(retmsg="Not supported yet!")
368
 
369
  e = DocumentService.update_by_id(doc.id,
370
- {"parser_id": req["parser_id"], "progress": 0, "progress_msg": "", "run": "0"})
 
371
  if not e:
372
  return get_data_error_result(retmsg="Document not found!")
373
  if "parser_config" in req:
 
367
  return get_data_error_result(retmsg="Not supported yet!")
368
 
369
  e = DocumentService.update_by_id(doc.id,
370
+ {"parser_id": req["parser_id"], "progress": 0, "progress_msg": "",
371
+ "run": TaskStatus.UNSTART.value})
372
  if not e:
373
  return get_data_error_result(retmsg="Document not found!")
374
  if "parser_config" in req:
api/db/__init__.py CHANGED
@@ -64,6 +64,7 @@ class ChatStyle(StrEnum):
64
 
65
 
66
  class TaskStatus(StrEnum):
 
67
  RUNNING = "1"
68
  CANCEL = "2"
69
  DONE = "3"
 
64
 
65
 
66
  class TaskStatus(StrEnum):
67
+ UNSTART = "0"
68
  RUNNING = "1"
69
  CANCEL = "2"
70
  DONE = "3"