feat(data-process): 返回任务文档数量

This commit is contained in:
caoxiaozhu
2026-07-27 09:50:19 +08:00
parent 680fa905f8
commit 895983ac20
3 changed files with 109 additions and 10 deletions

View File

@@ -37,7 +37,13 @@ class FakeDataProcessStore:
return f"{prefix}_{self.sequence}"
def list_tasks(self, *, page: int, page_size: int, **filters: Any) -> dict[str, Any]:
items = list(self.tasks.values())
items = [
{
**item,
"source_file_count": len(self.sources.get(str(item["id"]), [])),
}
for item in self.tasks.values()
]
for field in ("status", "process_type", "tenant_id", "project_id"):
if filters.get(field):
items = [item for item in items if item.get(field) == filters[field]]
@@ -673,6 +679,33 @@ def test_data_process_full_contract_without_database(tmp_path: Path) -> None:
)
def test_task_list_exposes_document_and_generation_counts(
tmp_path: Path,
) -> None:
client, store, _ = make_client(tmp_path)
task_id = client.post(
"/modelTF/data-process",
json={"name": "列表契约", "process_type": "unstructured", "config": {}},
).json()["data"]["id"]
store.sources[task_id] = [{"id": "source-1"}, {"id": "source-2"}]
store.tasks[task_id].update(
{
"status": "pending",
"output_count": 17,
"output_dataset_id": None,
}
)
response = client.get("/modelTF/data-process")
assert response.status_code == 200
item = response.json()["data"]["items"][0]
assert item["status"] == "pending"
assert item["source_file_count"] == 2
assert item["output_count"] == 17
assert item["output_dataset_id"] is None
def test_preview_build_replaces_only_selected_files_and_reports_file_counts(
tmp_path: Path,
) -> None: