fix task cancling bug (#98)

This commit is contained in:
KevinHuSh
2024-03-05 16:33:47 +08:00
committed by GitHub
parent 07d76ea18d
commit 602038ac49
11 changed files with 24 additions and 15 deletions

View File

@ -316,8 +316,7 @@ 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",
"token_num": 0, "chunk_num": 0, "process_duation": 0})
{"parser_id": req["parser_id"], "progress": 0, "progress_msg": "", "run": "0"})
if not e:
return get_data_error_result(retmsg="Document not found!")
if doc.token_num > 0:

View File

@ -73,8 +73,9 @@ class TaskService(CommonService):
@classmethod
@DB.connection_context()
def update_progress(cls, id, info):
cls.model.update(progress_msg=cls.model.progress_msg + "\n" + info["progress_msg"]).where(
cls.model.id == id).execute()
if info["progress_msg"]:
cls.model.update(progress_msg=cls.model.progress_msg + "\n" + info["progress_msg"]).where(
cls.model.id == id).execute()
if "progress" in info:
cls.model.update(progress=info["progress"]).where(
cls.model.id == id).execute()