feat(api): improve ID resolution in search and enable presenter file count
- In lib_sql_search, added a fallback to resolve random string IDs via Redis when the view lacks a dedicated _id_random column. - Un-commented file_count in Event_Presenter_Out_Base to support file tracking for presenters.
This commit is contained in:
@@ -248,10 +248,18 @@ def sql_search_qry_part(
|
||||
target_field = candidate_field
|
||||
# print(f"Search Trace: Mapping filter field '{f.field}' -> '{target_field}'", flush=True)
|
||||
else:
|
||||
# If random doesn't exist, we must stick to the integer column
|
||||
# but we'll need to resolve the string value to an integer elsewhere
|
||||
# or rely on the user providing an integer for now.
|
||||
pass
|
||||
# Fallback: Resolve ID if random column is missing from view
|
||||
try:
|
||||
from app.lib_redis_helpers import redis_lookup_id_random
|
||||
# Infer table name (e.g., 'event_id' -> 'event')
|
||||
if target_field.endswith('_id') and target_field != 'id':
|
||||
lookup_tbl = target_field[:-3] # remove '_id'
|
||||
resolved_id = redis_lookup_id_random(record_id_random=f.value, table_name=lookup_tbl)
|
||||
if resolved_id:
|
||||
# Update the filter value to use the resolved integer
|
||||
f.value = resolved_id
|
||||
except Exception as e:
|
||||
log.warning(f"Failed to resolve random ID for field {target_field}: {e}")
|
||||
|
||||
if searchable_fields is not None and target_field not in searchable_fields:
|
||||
# Fallback check for original field just in case
|
||||
|
||||
Reference in New Issue
Block a user