Work on sort of ressults using the priorty and sort fields.

This commit is contained in:
Scott Idem
2022-09-22 14:54:51 -04:00
parent ed7e06b5b2
commit aa981b0913
13 changed files with 30 additions and 27 deletions

View File

@@ -47,22 +47,22 @@ def get_lu_post_topic_rec_list(
if account_id:
data['account_id'] = account_id
sql_account_id = f'`tbl`.account_id = :account_id'
sql_account_id = f'`lu_post_topic`.account_id = :account_id'
else:
sql_account_id = ''
if for_type:
data['for_type'] = for_type
sql_for_type = f'AND `tbl`.for_type = :for_type'
sql_for_type = f'AND `lu_post_topic`.for_type = :for_type'
else:
sql_for_type = ''
if inc_admin_options:
data['admin_option'] = [0, 1]
sql_admin_option = f'AND `tbl`.admin_option IN :admin_option'
sql_admin_option = f'AND `lu_post_topic`.admin_option IN :admin_option'
else:
data['admin_option'] = [0]
sql_admin_option = f'AND `tbl`.admin_option IN :admin_option'
sql_admin_option = f'AND `lu_post_topic`.admin_option IN :admin_option'
if limit:
data['limit'] = limit
@@ -71,13 +71,13 @@ def get_lu_post_topic_rec_list(
sql_limit = ''
sql = f"""
SELECT * /*`tbl`.id AS 'lu_post_topic_id'*/
FROM `lu_post_topic` AS `tbl`
SELECT * /*`lu_post_topic`.id AS 'lu_post_topic_id'*/
FROM `lu_post_topic` AS `lu_post_topic`
WHERE
{sql_account_id}
{sql_for_type}
{sql_admin_option}
ORDER BY `tbl`.sort DESC
ORDER BY -`lu_post_topic`.sort DESC
{sql_limit};
"""