Skip to content

Commit

Permalink
add iso inf accordingly to hdx table
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jan 20, 2024
1 parent 981d3be commit 39818f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions src/query_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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}'
"""
Expand Down

0 comments on commit 39818f7

Please sign in to comment.