From 98a0eb2a8937e495b5df79d7a89c2a97eb4bb7b7 Mon Sep 17 00:00:00 2001 From: sujanadh Date: Tue, 7 Nov 2023 13:06:43 +0545 Subject: [PATCH] feat: added task_id on features extracted file --- src/backend/app/projects/project_crud.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index e500d95ee1..56cfe7bb87 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -1681,6 +1681,12 @@ def get_task_geometry(db: Session, project_id: int): async def get_project_features_geojson(db: Session, project_id: int): + db_tasks = ( + db.query(db_models.DbFeatures) + .filter(db_models.DbFeatures.project_id == project_id) + .all() + ) + """Get a geojson of all features for a task.""" query = text( f"""SELECT jsonb_build_object( @@ -1702,6 +1708,11 @@ async def get_project_features_geojson(db: Session, project_id: int): result = db.execute(query) features = result.fetchone()[0] + for feature in features["features"]: + for task in db_tasks: + if task.id == feature["id"]: + feature["properties"]["task_id"]=task.task_id + return features