Skip to content

Commit

Permalink
Fix Query filter condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jan 12, 2024
1 parent 8b73004 commit 65e5a6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions API/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def get_task_status(
"""
task_result = AsyncResult(task_id, app=celery)

task_response_result = None
if task_result.status == "SUCCESS":
task_response_result = task_result.result
Expand Down
4 changes: 2 additions & 2 deletions src/query_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_query_as_geojson(query_list, ogr_export=None):
def create_geom_filter(geom, geom_lookup_by="ST_intersects"):
"""generates geometry intersection filter - Rawdata extraction"""
geometry_dump = dumps(loads(geom.model_dump_json()))
return f"""{geom_lookup_by}(geom,ST_Buffer(ST_Union(ST_makeValid(ST_GEOMFROMGEOJSON('{geometry_dump}'))),0.005))"""
return f"""{geom_lookup_by}(geom,ST_Buffer((select ST_Union(ST_makeValid(ST_GEOMFROMGEOJSON('{geometry_dump}')))),0.005))"""


def format_file_name_str(input_str):
Expand Down Expand Up @@ -898,7 +898,7 @@ def convert_tags_pattern(query_string):
row_filter_condition = (
f"""(country <@ ARRAY [{cid}])"""
if cid
else f"""(ST_within(geom,ST_Buffer(ST_Union(ST_makeValid(ST_GeomFromText('{wkt.dumps(loads(geometry.json()),decimals=6)}',4326))),0.005)))"""
else f"""(ST_within(geom,ST_Buffer((select ST_Union(ST_makeValid(ST_GeomFromText('{wkt.dumps(loads(geometry.json()),decimals=6)}',4326)))),0.005)))"""
)
if single_category_where:
row_filter_condition += f" and ({convert_tags_pattern(single_category_where)})"
Expand Down

0 comments on commit 65e5a6f

Please sign in to comment.