From 39818f7e841b79be97db7ac34bce34837f2f8642 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Sat, 20 Jan 2024 11:41:09 +0545 Subject: [PATCH] add iso inf accordingly to hdx table --- src/app.py | 9 +++++++-- src/query_builder/builder.py | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app.py b/src/app.py index 548440d5..05066f13 100644 --- a/src/app.py +++ b/src/app.py @@ -1934,7 +1934,11 @@ def create_hdx(self, hdx_data): ) self.con.commit() self.d_b.close_conn() - return {"create": True} + result = self.cur.fetchone() + if result: + return {"create": True} + raise HTTPException(status_code=500, detail="Insert failed") + def get_hdx_list_with_filters( self, skip: int = 0, limit: int = 10, filters: dict = {} @@ -2035,7 +2039,8 @@ def update_hdx(self, hdx_id: int, hdx_data): ) self.con.commit() self.d_b.close_conn() - + result = self.cur.fetchone() + if result: return {"update": True} raise HTTPException(status_code=404, detail="Item not found") diff --git a/src/query_builder/builder.py b/src/query_builder/builder.py index 6bdae952..a4712c8c 100644 --- a/src/query_builder/builder.py +++ b/src/query_builder/builder.py @@ -770,7 +770,7 @@ def raw_extract_plain_geojson(params, inspect_only=False): def get_countries_query(q): query = "Select ST_AsGeoJSON(cf.*) FROM countries cf" if q: - query += f" WHERE description ILIKE '%{q}%'" + query += f" WHERE name ILIKE '%{q}%'" return query @@ -850,9 +850,9 @@ def get_country_from_iso(iso3): str: SQL query to fetch country information. """ query = f"""SELECT - b.cid::int as fid, b.description as name, b.dataset_name as dataset_prefix, b.locations as locations + b.cid::int as fid, b.dataset->>'dataset_title' as dataset_title, b.dataset->>'dataset_prefix' as dataset_prefix, b.dataset->>'dataset_locations' as locations FROM - countries b + hdx b WHERE LOWER(iso_3) = '{iso3}' """