mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-31 02:01:57 +08:00
Feat: Improve "/convert" API's performance (#6465)
### What problem does this PR solve? for batch requests based on get_by_ids to fetch all files first replace the O(n) IO logic. ### Type of change - [x] Performance Improvement
This commit is contained in:
parent
3c57a9986c
commit
f691b4ddd2
@ -38,8 +38,12 @@ def convert():
|
|||||||
file2documents = []
|
file2documents = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
files = FileService.get_by_ids(file_ids)
|
||||||
|
files_set = set([file.id for file in files])
|
||||||
for file_id in file_ids:
|
for file_id in file_ids:
|
||||||
e, file = FileService.get_by_id(file_id)
|
file = files_set[file_id]
|
||||||
|
if not file:
|
||||||
|
return get_data_error_result(message="File not found!")
|
||||||
file_ids_list = [file_id]
|
file_ids_list = [file_id]
|
||||||
if file.type == FileType.FOLDER.value:
|
if file.type == FileType.FOLDER.value:
|
||||||
file_ids_list = FileService.get_all_innermost_file_ids(file_id, [])
|
file_ids_list = FileService.get_all_innermost_file_ids(file_id, [])
|
||||||
@ -86,6 +90,7 @@ def convert():
|
|||||||
"file_id": id,
|
"file_id": id,
|
||||||
"document_id": doc.id,
|
"document_id": doc.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
file2documents.append(file2document.to_json())
|
file2documents.append(file2document.to_json())
|
||||||
return get_json_result(data=file2documents)
|
return get_json_result(data=file2documents)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user