Skip to content

Commit

Permalink
feat: added task_id on features extracted file
Browse files Browse the repository at this point in the history
  • Loading branch information
sujanadh committed Nov 7, 2023
1 parent 03b80e1 commit 98a0eb2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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


Expand Down

0 comments on commit 98a0eb2

Please sign in to comment.