From c6707dd1e818cd1ff84a016c6de7cda5f611a530 Mon Sep 17 00:00:00 2001 From: Anuj Gupta <84966248+Anuj-Gupta4@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:08:59 +0545 Subject: [PATCH] fix(backend): include organisation name in minimal project query results (#1993) --- src/backend/app/db/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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