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

@@ -23,7 +23,7 @@ def load_cont_edu_cert_person_obj(
enabled: str = 'enabled', # enabled, disabled, all
inc_cont_edu_cert: bool = False,
) -> Cont_Edu_Cert_Person_Base|dict|bool:
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if cont_edu_cert_person_id := redis_lookup_id_random(record_id_random=cont_edu_cert_person_id, table_name='cont_edu_cert_person'): pass
@@ -73,7 +73,7 @@ def get_cont_edu_cert_person_rec_list(
limit: int = 1000,
enabled: str = 'enabled', # enabled, disabled, all
) -> None|list|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if cont_edu_cert_id:
@@ -132,10 +132,13 @@ def get_cont_edu_cert_person_rec_list(
ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC
{sql_limit};
"""
log.debug(sql)
if cont_edu_cert_person_rec_li_result := sql_select(data=data, sql=sql):
log.info('Got a list result')
cont_edu_cert_person_rec_li = cont_edu_cert_person_rec_li_result
else: # None or False
log.info('No results or something went wrong')
cont_edu_cert_person_rec_li = cont_edu_cert_person_rec_li_result # []
log.debug(cont_edu_cert_person_rec_li_result)