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 18:55:31 -05:00
parent 92a44b9f41
commit 39db1999fb
27 changed files with 301 additions and 239 deletions

View File

@@ -567,7 +567,7 @@ def load_account_obj(
# ### BEGIN ### API Account Methods ### get_account_rec_list() ###
# Updated 2021-09-28
# Updated 2021-12-13
def get_account_rec_list(
limit: int = 25,
enabled: str = 'enabled', # enabled, disabled, all
@@ -604,12 +604,15 @@ def get_account_rec_list(
ORDER BY `account`.created_on DESC, `account`.updated_on DESC
{sql_limit};
"""
log.debug(sql)
if account_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
log.info('Got a list result')
account_rec_li = account_rec_li_result
else:
account_rec_li = []
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
else: # [] or False
log.info('No results or something went wrong')
account_rec_li = account_rec_li_result
log.debug(account_rec_li_result)
return account_rec_li