Skip to content

Commit

Permalink
updated raw sql query in generate app user files
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Sep 5, 2023
1 parent c430ea9 commit b07e814
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ def generate_task_files(
# Get the features for this task.
# Postgis query to filter task inside this task outline and of this project
# Update those features and set task_id
query = f"""UPDATE features
query = text(f"""UPDATE features
SET task_id={task_id}
WHERE id IN (
SELECT id
Expand All @@ -1216,12 +1216,12 @@ def generate_task_files(
AND ST_IsValid(geometry)
AND ST_IsValid('{task.outline}'::Geometry)
AND ST_Contains('{task.outline}'::Geometry, ST_Centroid(geometry))
)"""
)""")

result = db.execute(query)

# Get the geojson of those features for this task.
query = f"""SELECT jsonb_build_object(
query = text(f"""SELECT jsonb_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
Expand All @@ -1234,9 +1234,10 @@ def generate_task_files(
) AS feature
FROM features
WHERE project_id={project_id} and task_id={task_id}
) features;"""
) features;""")

result = db.execute(query)

features = result.fetchone()[0]

upload_media = False if features['features'] is None else True
Expand Down

0 comments on commit b07e814

Please sign in to comment.