mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-06-26 22:19:57 +00:00
Fix: chunk number error after re-parsing (#8513)
### What problem does this PR solve? Fix chunk number error after re-parsing. #8503. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
05bf01b058
commit
d768130204
@ -365,6 +365,13 @@ def run():
|
|||||||
info["progress_msg"] = ""
|
info["progress_msg"] = ""
|
||||||
info["chunk_num"] = 0
|
info["chunk_num"] = 0
|
||||||
info["token_num"] = 0
|
info["token_num"] = 0
|
||||||
|
|
||||||
|
e, doc = DocumentService.get_by_id(id)
|
||||||
|
if not e:
|
||||||
|
return get_data_error_result(message="Document not found!")
|
||||||
|
if doc.run == TaskStatus.DONE.value:
|
||||||
|
DocumentService.clear_chunk_num_when_rerun(doc.id)
|
||||||
|
|
||||||
DocumentService.update_by_id(id, info)
|
DocumentService.update_by_id(id, info)
|
||||||
tenant_id = DocumentService.get_tenant_id(id)
|
tenant_id = DocumentService.get_tenant_id(id)
|
||||||
if not tenant_id:
|
if not tenant_id:
|
||||||
|
@ -279,6 +279,24 @@ class DocumentService(CommonService):
|
|||||||
Knowledgebase.id == doc.kb_id).execute()
|
Knowledgebase.id == doc.kb_id).execute()
|
||||||
return num
|
return num
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@DB.connection_context()
|
||||||
|
def clear_chunk_num_when_rerun(cls, doc_id):
|
||||||
|
doc = cls.model.get_by_id(doc_id)
|
||||||
|
assert doc, "Can't fine document in database."
|
||||||
|
|
||||||
|
num = (
|
||||||
|
Knowledgebase.update(
|
||||||
|
token_num=Knowledgebase.token_num - doc.token_num,
|
||||||
|
chunk_num=Knowledgebase.chunk_num - doc.chunk_num,
|
||||||
|
)
|
||||||
|
.where(Knowledgebase.id == doc.kb_id)
|
||||||
|
.execute()
|
||||||
|
)
|
||||||
|
return num
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@DB.connection_context()
|
@DB.connection_context()
|
||||||
def get_tenant_id(cls, doc_id):
|
def get_tenant_id(cls, doc_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user