Work on sort of ressults using the priorty and sort fields.
This commit is contained in:
@@ -254,7 +254,7 @@ def get_event_exhibit_rec_list(
|
||||
{sql_select_event_exhibit_id}
|
||||
{sql_select_event_person_id}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_exhibit`.priority DESC, `event_exhibit`.sort ASC, `event_exhibit`.name ASC, `event_exhibit`.created_on DESC, `event_exhibit`.updated_on DESC
|
||||
ORDER BY `event_exhibit`.priority DESC, -`event_exhibit`.sort DESC, `event_exhibit`.name ASC, `event_exhibit`.created_on DESC, `event_exhibit`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -317,7 +317,7 @@ def get_event_exhibit_tracking_rec_list(
|
||||
{sql_select_event_person_id}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_exhibit_tracking`.priority DESC, `event_exhibit_tracking`.sort ASC, `event_exhibit_tracking`.created_on DESC, `event_exhibit_tracking`.updated_on DESC
|
||||
ORDER BY `event_exhibit_tracking`.priority DESC, -`event_exhibit_tracking`.sort DESC, `event_exhibit_tracking`.created_on DESC, `event_exhibit_tracking`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -177,7 +177,7 @@ def get_event_file_rec_list(
|
||||
{sql_priority}
|
||||
{sql_group}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_file`.created_on DESC, `event_file`.updated_on DESC
|
||||
ORDER BY `event_file`.priority DESC, -`event_file`.sort DESC, `event_file`.created_on DESC, `event_file`.updated_on DESC, `event_file`.filename ASC, `event_file`.extension ASC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -260,7 +260,7 @@ def get_event_location_rec_list(
|
||||
{sql_where_event_id}
|
||||
{sql_enabled}
|
||||
{sql_hidden}
|
||||
ORDER BY `event_location`.priority DESC, `event_location`.sort ASC, `event_location`.name ASC, `event_location`.created_on DESC, `event_location`.updated_on DESC
|
||||
ORDER BY `event_location`.priority DESC, -`event_location`.sort DESC, `event_location`.name ASC, `event_location`.created_on DESC, `event_location`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -644,7 +644,7 @@ def get_event_meeting_rec_list(
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event`.priority DESC, `event`.sort ASC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
ORDER BY `event`.priority DESC, -`event`.sort DESC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
elif conference and (organization_id or person_id or user_id): # If it is a conference then organization, person, and user are queried as participants (not the owner/organizer)
|
||||
@@ -665,7 +665,7 @@ def get_event_meeting_rec_list(
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event`.priority DESC, `event`.sort ASC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
ORDER BY `event`.priority DESC, -`event`.sort DESC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -164,7 +164,7 @@ def load_event_presentation_obj(
|
||||
WHERE `event_presenter`.event_presentation_id = :event_presentation_id
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_presenter`.priority DESC, `event_presenter`.sort ASC, `event_presenter`.family_name ASC, `event_presenter`.given_name ASC, `event_presenter`.display_name ASC, `event_presenter`.full_name ASC, `event_presenter`.created_on DESC, `event_presenter`.updated_on DESC;
|
||||
ORDER BY `event_presenter`.priority DESC, -`event_presenter`.sort DESC, `event_presenter`.family_name ASC, `event_presenter`.given_name ASC, `event_presenter`.display_name ASC, `event_presenter`.full_name ASC, `event_presenter`.created_on DESC, `event_presenter`.updated_on DESC;
|
||||
"""
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(sql)
|
||||
@@ -296,7 +296,7 @@ def get_event_presentation_rec_list(
|
||||
{sql_where_event_session_id}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_presentation`.priority DESC, `event_presentation`.sort ASC, `event_presentation`.start_datetime ASC, `event_presentation`.sort ASC, `event_presentation`.name ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC
|
||||
ORDER BY `event_presentation`.priority DESC, -`event_presentation`.sort DESC, `event_presentation`.start_datetime ASC, `event_presentation`.name ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ def get_event_presenter_rec_list(
|
||||
{sql_where_event_presentation_id}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_presenter`.priority DESC, `event_presenter`.sort ASC, `event_presenter`.family_name ASC, `event_presenter`.given_name ASC, `event_presenter`.display_name ASC, `event_presenter`.full_name ASC, `event_presenter`.created_on DESC, `event_presenter`.updated_on DESC
|
||||
ORDER BY `event_presenter`.priority DESC, -`event_presenter`.sort DESC, `event_presenter`.family_name ASC, `event_presenter`.given_name ASC, `event_presenter`.display_name ASC, `event_presenter`.full_name ASC, `event_presenter`.created_on DESC, `event_presenter`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ def load_event_session_obj(
|
||||
WHERE `event_presentation`.event_session_id = :event_session_id
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_presentation`.priority DESC, `event_presentation`.sort ASC, `event_presentation`.start_datetime ASC, `event_presentation`.sort ASC, `event_presentation`.name ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC;
|
||||
ORDER BY `event_presentation`.priority DESC, -`event_presentation`.sort DESC, `event_presentation`.start_datetime ASC, `event_presentation`.name ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC;
|
||||
"""
|
||||
|
||||
if event_presentation_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
@@ -321,7 +321,7 @@ def load_event_session_obj(
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Session Methods ### get_event_session_rec_list() ###
|
||||
# Updated 2021-12-13
|
||||
# Updated 2022-09-22
|
||||
@logger_reset
|
||||
def get_event_session_rec_list(
|
||||
event_id: str = None,
|
||||
@@ -406,7 +406,7 @@ def get_event_session_rec_list(
|
||||
{sql_approved}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_session`.priority DESC, `event_session`.sort ASC, `event_session`.start_datetime ASC, `event_session`.name ASC, `event_session`.created_on DESC, `event_session`.updated_on DESC
|
||||
ORDER BY `event_session`.priority DESC, -`event_session`.sort DESC, `event_session`.start_datetime ASC, `event_session`.name ASC, `event_session`.created_on DESC, `event_session`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
@@ -581,7 +581,7 @@ def delete_hosted_file_link(
|
||||
# ### BEGIN ### API Hosted File Methods ### get_hosted_file_rec_list() ###
|
||||
# This needs to be improved. Currently it does not really do anything.
|
||||
# Need to allow for list by account? Probably have the same actual hosted file have two hosted_file entries if it was uploaded for two separate accounts.
|
||||
# Updated 2022
|
||||
# Updated 2022-09-22
|
||||
@logger_reset
|
||||
def get_hosted_file_rec_list(
|
||||
for_obj_type: str,
|
||||
@@ -616,15 +616,18 @@ def get_hosted_file_rec_list(
|
||||
sql_limit = ''
|
||||
|
||||
sql = f"""
|
||||
SELECT `tbl`.id AS 'hosted_file_id', `tbl`.id_random AS 'hosted_file_id_random'
|
||||
FROM `hosted_file` AS `tbl`
|
||||
SELECT `hosted_file`.id AS 'hosted_file_id', `hosted_file`.id_random AS 'hosted_file_id_random'
|
||||
FROM `hosted_file` AS `hosted_file`
|
||||
WHERE
|
||||
{sql_obj_type_id}
|
||||
{sql_enabled}
|
||||
ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC
|
||||
ORDER BY `hosted_file`.created_on DESC, `hosted_file`.updated_on DESC, `hosted_file`.filename ASC, `hosted_file`.extension ASC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
# NOTE: Use the ORDER BY below if priority and sort fields are added to the hosted_file table.
|
||||
# /* ORDER BY `hosted_file`.priority DESC, -`hosted_file`.sort DESC, `hosted_file`.created_on DESC, `hosted_file`.updated_on DESC, `hosted_file`.filename ASC, `hosted_file`.extension ASC */
|
||||
|
||||
if hosted_file_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
hosted_file_rec_li = hosted_file_rec_li_result
|
||||
else:
|
||||
|
||||
@@ -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};
|
||||
"""
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ def get_membership_group_rec_list(
|
||||
WHERE
|
||||
{sql_account_id}
|
||||
{sql_enabled}
|
||||
ORDER BY `membership_group`.sort ASC, `membership_group`.created_on DESC, `membership_group`.updated_on DESC
|
||||
ORDER BY -`membership_group`.sort DESC, `membership_group`.created_on DESC, `membership_group`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
@@ -214,7 +214,7 @@ def get_membership_group_rec_list(
|
||||
WHERE
|
||||
{sql_membership_person_id}
|
||||
{sql_enabled}
|
||||
ORDER BY `membership_person_group`.sort ASC, `membership_person_group`.created_on DESC, `membership_person_group`.updated_on DESC
|
||||
ORDER BY -`membership_person_group`.sort DESC, `membership_person_group`.created_on DESC, `membership_person_group`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
else: return False
|
||||
|
||||
@@ -176,7 +176,7 @@ def get_membership_type_rec_list(
|
||||
{sql_account_id}
|
||||
{sql_type_level}
|
||||
{sql_enabled}
|
||||
ORDER BY `membership_type`.sort ASC, `membership_type`.created_on DESC, `membership_type`.updated_on DESC
|
||||
ORDER BY -`membership_type`.sort DESC, `membership_type`.created_on DESC, `membership_type`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ def get_person_rec_list(
|
||||
{sql_obj_type_id}
|
||||
{sql_where_email}
|
||||
{sql_enabled}
|
||||
ORDER BY `person`.priority DESC, `person`.sort ASC,`person`.given_name ASC, `person`.family_name ASC, `person`.created_on DESC, `person`.updated_on DESC
|
||||
ORDER BY `person`.priority DESC, -`person`.sort DESC,`person`.given_name ASC, `person`.family_name ASC, `person`.created_on DESC, `person`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
Reference in New Issue
Block a user