Skip to content

Commit

Permalink
Merge pull request #193 from hotosm/fix/bug_empty_category
Browse files Browse the repository at this point in the history
BUG : Fix empty category issue
  • Loading branch information
kshitijrajsharma authored Dec 28, 2023
2 parents 3244b0d + 27c4bbe commit 1c78e11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
21 changes: 16 additions & 5 deletions API/hdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ async def process_custom_requests(
],
"where": "tags['building'] IS NOT NULL",
"formats": ["geojson", "shp", "kml"],
},
}
},
{
"Roads": {
"types": ["lines"],
"select": [
Expand All @@ -181,7 +183,9 @@ async def process_custom_requests(
],
"where": "tags['highway'] IS NOT NULL",
"formats": ["geojson", "shp", "kml"],
},
}
},
{
"Waterways": {
"types": ["lines", "polygons"],
"select": [
Expand All @@ -199,14 +203,16 @@ async def process_custom_requests(
],
"where": "tags['waterway'] IS NOT NULL OR tags['water'] IS NOT NULL OR tags['natural'] IN ('water','wetland','bay')",
"formats": ["geojson", "shp", "kml"],
},
}
},
{
"Landuse": {
"types": ["points", "polygons"],
"select": ["name", "amenity", "landuse", "leisure"],
"where": "tags['landuse'] IS NOT NULL",
"formats": ["geojson", "shp", "kml"],
},
}
}
},
],
},
},
Expand Down Expand Up @@ -783,6 +789,11 @@ async def process_custom_requests(
status_code=403,
detail=[{"msg": "Insufficient Permission to choose queue"}],
)
params.categories = [category for category in params.categories if category]
if len(params.categories) == 0:
raise HTTPException(
status_code=400, detail=[{"msg": "Categories can't be empty"}]
)
task = process_hdx_request.apply_async(
args=(params.model_dump(),), queue=queue_name, track_started=True
)
Expand Down
5 changes: 5 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,9 +1572,14 @@ def process_hdx_tags(self):
"""
started_at = datetime.now().isoformat()
processing_time_start = time.time()
# clean cateories remove {}
self.params.categories = [
category for category in self.params.categories if category
]
table_type = [
cat_type
for category in self.params.categories
if category
for cat_type in list(category.values())[0].types
]
where_0_category = None
Expand Down

0 comments on commit 1c78e11

Please sign in to comment.