From 65e5a6faa95ed1c3216a866be791a16bfaa8d728 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Fri, 12 Jan 2024 09:53:13 +0545 Subject: [PATCH] Fix Query filter condition --- API/tasks.py | 1 + src/query_builder/builder.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/API/tasks.py b/API/tasks.py index ff1b4ab2..0768d697 100644 --- a/API/tasks.py +++ b/API/tasks.py @@ -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 diff --git a/src/query_builder/builder.py b/src/query_builder/builder.py index 5b573d9a..6f4a8a5c 100644 --- a/src/query_builder/builder.py +++ b/src/query_builder/builder.py @@ -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): @@ -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)})"