Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/Include organisation name in mapper frontend's project api #1993

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading