fix(project): expose uploaded files in project _to_dict response

Add _get_project_files classmethod that queries ProjectFileModel for
file_type=="upload" records, and wire it into _to_dict replacing the
hardcoded empty list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-05-15 22:15:13 +00:00
parent 0d5a2cf993
commit 123be0eea9
1 changed files with 21 additions and 1 deletions

View File

@ -240,6 +240,26 @@ class ProjectManager:
rec.edge_count = edge_count rec.edge_count = edge_count
db.commit() db.commit()
@classmethod
def _get_project_files(cls, project_id: str) -> list:
from sqlalchemy import select
with get_session() as db:
stmt = select(ProjectFileModel).where(
ProjectFileModel.project_id == project_id,
ProjectFileModel.file_type == "upload",
)
files = db.execute(stmt).scalars().all()
return [
{
"file_id": f.id,
"filename": f.original_name,
"size": f.size,
"mime_type": f.mime_type,
"storage_path": f.storage_path,
}
for f in files
]
@classmethod @classmethod
def _to_dict(cls, proj: "ProjectModel") -> Dict[str, Any]: def _to_dict(cls, proj: "ProjectModel") -> Dict[str, Any]:
import os, json as _json import os, json as _json
@ -291,7 +311,7 @@ class ProjectManager:
"active_task_id": proj.active_task_id, "active_task_id": proj.active_task_id,
"created_at": proj.created_at.isoformat(), "created_at": proj.created_at.isoformat(),
"updated_at": proj.updated_at.isoformat(), "updated_at": proj.updated_at.isoformat(),
"files": [], "files": cls._get_project_files(proj.id),
"total_text_length": 0, "total_text_length": 0,
"ontology": ontology, "ontology": ontology,
"graph_id": graph_external_id, "graph_id": graph_external_id,