Skip to content

Commit

Permalink
fix(backend): include organisation name in minimal project query resu…
Browse files Browse the repository at this point in the history
…lts (#1993)
  • Loading branch information
Anuj-Gupta4 authored Dec 16, 2024
1 parent 259c256 commit c6707dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit c6707dd

Please sign in to comment.