Code clean up. Working on returning proper 404 vs 400 responses if the results are empty and nothing went wrong.

This commit is contained in:
Scott Idem
2021-12-13 17:02:21 -05:00
parent 2ef53d7a51
commit 133cfab42f
10 changed files with 131 additions and 100 deletions

View File

@@ -96,7 +96,7 @@ async def get_event_location_obj(
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if event_location_id := redis_lookup_id_random(record_id_random=event_location_id, table_name='event_location'): pass
@@ -125,7 +125,7 @@ async def get_event_location_obj(
# ### BEGIN ### API Event Location ### get_event_obj_event_location_list() ###
# Updated 2021-11-10
# Updated 2021-12-13
@router.get('/event/{event_id}/event/location/list', response_model=Resp_Body_Base)
async def get_event_obj_event_location_list(
event_id: str = Query(..., min_length=11, max_length=22),
@@ -170,7 +170,11 @@ async def get_event_obj_event_location_list(
else:
event_location_result_list.append(None)
response_data = event_location_result_list
elif event_location_rec_list_result is None:
log.info('No results')
return mk_resp(data=None, status_code=404, response=response) # Not Found
else:
log.warning('Likely bad request')
return mk_resp(data=False, status_code=400, response=response) # Bad Request
return mk_resp(data=response_data, response=response)