Work on archives

This commit is contained in:
Scott Idem
2021-11-01 17:17:02 -04:00
parent f31626f51c
commit 82a6cb4525
5 changed files with 80 additions and 18 deletions

View File

@@ -51,6 +51,9 @@ def get_archive_content_rec_list(
for_obj_id: str,
limit: int = 1000,
enabled: str = 'enabled', # enabled, disabled, all
sort_by_str: str = None,
sort_by: str = None,
sort_by_desc: bool = False,
) -> list|bool:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -78,13 +81,20 @@ def get_archive_content_rec_list(
else:
sql_limit = ''
if sort_by:
sql_order_by = f'ORDER BY `tbl`.{sort_by}'
if sort_by_desc:
sql_order_by = f'{sql_order_by} {DESC}'
else:
sql_order_by = 'ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC'
sql = f"""
SELECT `tbl`.id AS 'archive_content_id', `tbl`.id_random AS 'archive_content_id_random'
FROM `archive_content` AS `tbl`
WHERE
{sql_obj_type_id}
{sql_enabled}
ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC
{sql_order_by}
{sql_limit};
"""