From 123be0eea97117feea39419e092468b74817d97d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 15 May 2026 22:15:13 +0000 Subject: [PATCH] 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 --- backend/app/models/project.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/app/models/project.py b/backend/app/models/project.py index f5dad2e4..807ab867 100644 --- a/backend/app/models/project.py +++ b/backend/app/models/project.py @@ -240,6 +240,26 @@ class ProjectManager: rec.edge_count = edge_count 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 def _to_dict(cls, proj: "ProjectModel") -> Dict[str, Any]: import os, json as _json @@ -291,7 +311,7 @@ class ProjectManager: "active_task_id": proj.active_task_id, "created_at": proj.created_at.isoformat(), "updated_at": proj.updated_at.isoformat(), - "files": [], + "files": cls._get_project_files(proj.id), "total_text_length": 0, "ontology": ontology, "graph_id": graph_external_id,