Improve data store record retrieval.
This commit is contained in:
@@ -55,6 +55,8 @@ def load_data_store_obj(
|
||||
def load_data_store_obj_w_code(
|
||||
account_id: int,
|
||||
code: str,
|
||||
for_type: int = None,
|
||||
for_id: int = None,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
limit: int = 1,
|
||||
offset: int = 0,
|
||||
@@ -68,9 +70,18 @@ def load_data_store_obj_w_code(
|
||||
data = {}
|
||||
data['account_id'] = account_id
|
||||
data['code'] = code
|
||||
data['for_type'] = for_type
|
||||
data['for_id'] = for_id
|
||||
|
||||
log.debug(data)
|
||||
# log.warning(f'Can we get past this?????????? {code}')
|
||||
# if for_id := redis_lookup_id_random(record_id_random=for_id, table_name=for_type): pass
|
||||
# else: return False
|
||||
|
||||
if for_type and for_id:
|
||||
sql_for_type_id = 'AND `data_store`.for_type = :for_type AND `data_store`.for_id = :for_id'
|
||||
else:
|
||||
sql_for_type_id = 'AND `data_store`.for_type IS NULL AND `data_store`.for_id IS NULL'
|
||||
|
||||
sql_enabled, data['enable'] = sql_enable_part(table_name='data_store', enabled=enabled) # Reasonably safe return str and bool
|
||||
sql_limit = sql_limit_offset_part(limit=limit, offset=offset) # Reasonably safe return str
|
||||
@@ -87,6 +98,7 @@ def load_data_store_obj_w_code(
|
||||
OR `data_store`.account_id IS NULL
|
||||
)
|
||||
AND `data_store`.code = :code
|
||||
{sql_for_type_id}
|
||||
{sql_enabled}
|
||||
ORDER BY `data_store`.account_id DESC, `data_store`.created_on DESC, `data_store`.updated_on DESC
|
||||
{sql_limit};
|
||||
|
||||
@@ -173,7 +173,7 @@ def get_event_abstract_rec_list(
|
||||
|
||||
if event_id:
|
||||
data['event_id'] = event_id
|
||||
sql_event_id = f'AND `event_abstract`.event_id = :event_id'
|
||||
sql_event_id = f'`event_abstract`.event_id = :event_id'
|
||||
else: sql_event_id = '1=1'
|
||||
|
||||
if event_person_id:
|
||||
|
||||
Reference in New Issue
Block a user