diff --git a/src/backend/app/db/models.py b/src/backend/app/db/models.py index 043a9757b..212d475ee 100644 --- a/src/backend/app/db/models.py +++ b/src/backend/app/db/models.py @@ -1015,6 +1015,7 @@ async def one(cls, db: Connection, project_id: int, minimal: bool = False) -> Se sql = """ SELECT p.*, + project_org.name AS organisation_name, ST_AsGeoJSON(p.outline)::jsonb AS outline, ST_AsGeoJSON(ST_Centroid(p.outline))::jsonb AS centroid, COALESCE( @@ -1032,13 +1033,15 @@ async def one(cls, db: Connection, project_id: int, minimal: bool = False) -> Se projects p LEFT JOIN tasks t ON t.project_id = %(project_id)s + LEFT JOIN + organisations project_org ON p.organisation_id = project_org.id WHERE p.id = %(project_id)s AND ( t.project_id = %(project_id)s -- Also required to return a project with if tasks OR t.project_id IS NULL ) - GROUP BY p.id; + GROUP BY p.id, project_org.name; """ # Full query with all additional calculated fields