Work on archives
This commit is contained in:
@@ -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};
|
||||
"""
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ def load_archive_obj(
|
||||
exclude_unset: bool = True,
|
||||
model_as_dict: bool = False,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
inc_archive_content_list: bool = False,
|
||||
) -> Archive_Base|dict|bool:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -42,11 +43,15 @@ def load_archive_obj(
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_archive_content_list:
|
||||
sort_by = archive_rec.get('sort_by')
|
||||
sort_by_desc = archive_rec.get('sort_by_desc')
|
||||
if archive_content_rec_list_result := get_archive_content_rec_list(
|
||||
for_obj_type = 'archive',
|
||||
for_obj_id = archive_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
sort_by = sort_by,
|
||||
sort_by_desc = sort_by_desc,
|
||||
):
|
||||
archive_content_result_list = []
|
||||
for archive_content_rec in archive_content_rec_list_result:
|
||||
|
||||
Reference in New Issue
Block a user