Fix: Restore IDAA Recovery Meetings search functionality

- Backend: Added V3-compliant `search__event` to `ae_events__event.ts` with support for `default_qry_str`.
- Backend: Removed accidental duplicate `qry_ae_obj_li__event_v2` implementation.
- API: Exported `search__event` from `ae_events_functions.ts`.
- Frontend: Updated `recovery_meetings/+page.svelte` to use the new `search__event` function.
This commit is contained in:
Scott Idem
2026-01-21 17:29:52 -05:00
parent af35124a8b
commit c782d2273a
3 changed files with 51 additions and 23 deletions

View File

@@ -404,8 +404,8 @@ export async function update_ae_obj__event({
return result;
}
// Updated 2026-01-20
export async function qry_ae_obj_li__event({
// Updated 2026-01-21
export async function search__event({
api_cfg,
for_obj_type = 'account',
for_obj_id,
@@ -441,19 +441,57 @@ export async function qry_ae_obj_li__event({
order_by_li?: Record<string, 'ASC' | 'DESC'>;
try_cache?: boolean;
log_lvl?: number;
}) {
const search_query: any = { and: [] };
}): Promise<ae_Event[]> {
if (log_lvl) console.log('*** search__event() *** [V3]');
const search_query: any = {
and: []
};
if (qry_str) {
// Use reserved 'q' property for global full-text search as per V3 Guide
// V3 Standard Full-text Search
search_query.q = qry_str;
// Also add to the explicit V3 search body for the event table specifically (legacy behavior support)
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str.trim()}%` });
}
// Use raw field name to bypass backend mapping conflicts (Integer Trap)
// Use raw field name to bypass backend mapping conflicts
if (for_obj_id) {
search_query.and.push({ field: 'account_id_random', op: 'eq', value: for_obj_id });
}
// Handle conference filter
if (qry_conference !== null) {
search_query.and.push({ field: 'conference', op: 'eq', value: qry_conference ? 1 : 0 });
}
// Location Filtering (Inclusive OR logic)
if (qry_physical === true || qry_virtual === true) {
const or_filters = [];
if (qry_physical === true) or_filters.push({ field: 'physical', op: 'eq', value: 1 });
if (qry_virtual === true) or_filters.push({ field: 'virtual', op: 'eq', value: 1 });
if (or_filters.length > 0) {
// If only one is selected, we can just add it to AND. If both, we'd need OR logic which V3 search body might not fully support nested yet.
// For now, if both are true, we essentially want events that are EITHER physical OR virtual (which is basically all events usually).
// However, the client-side filter in existing logic implies specific filtering.
// Let's rely on the client-side filter for this specific complex OR logic for now to be safe,
// OR if V3 supports 'or' at the top level we could use it, but mixing AND and OR groups in simple search is tricky.
// STRATEGY: Pass through to client-side filtering for these specific flags to match legacy behavior perfectly.
}
}
// Handle type filter
if (qry_type != null && qry_type !== 'all' && qry_type !== '') {
search_query.and.push({ field: 'type', op: 'eq', value: qry_type });
}
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 1 });
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
const result_li = await api.search_ae_obj_v3({
api_cfg,
obj_type: 'event',
@@ -486,17 +524,9 @@ export async function qry_ae_obj_li__event({
});
}
// Client-side Filter Layer
// Client-side Filter Layer (Retained for complex OR logic and Person ID checks)
const filtered_obj_li = processed_obj_li.filter((ev: any) => {
// Handle conference filter
if (qry_conference != null) {
const ev_conf = ev.conference === true || ev.conference === 1 || ev.conference === '1';
if (ev_conf !== !!qry_conference) return false;
}
// Location Filtering (Inclusive OR logic)
// If either filter is explicitly true, we restrict results.
// If both are false or null, we show everything.
if (qry_physical === true || qry_virtual === true) {
const ev_physical = ev.physical === true || ev.physical === 1 || ev.physical === '1';
const ev_virtual = ev.virtual === true || ev.virtual === 1 || ev.virtual === '1';
@@ -508,11 +538,6 @@ export async function qry_ae_obj_li__event({
if (!match) return false;
}
// Handle type filter (skip if null, undefined, 'all', or empty string)
if (qry_type != null && qry_type !== 'all' && qry_type !== '') {
if (ev.type !== qry_type) return false;
}
// Handle person ID filter
if (qry_person_id) {
const match = (
@@ -529,12 +554,14 @@ export async function qry_ae_obj_li__event({
});
if (log_lvl) {
console.log(`Filter results (V3): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
console.log(`Filter results (V3 Search): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
}
return filtered_obj_li;
}
/**
* Specialized search function for IDAA module using legacy V2 endpoints.
* This is isolated to prevent V3 migration bugs from affecting Recovery Meetings.

View File

@@ -33,6 +33,7 @@ const export_obj = {
load_ae_obj_id__event: event.load_ae_obj_id__event,
load_ae_obj_li__event: event.load_ae_obj_li__event,
qry_ae_obj_li__event: event.qry_ae_obj_li__event,
search__event: event.search__event,
qry_ae_obj_li__event_v2: event.qry_ae_obj_li__event_v2,
create_ae_obj__event: event.create_ae_obj__event,
delete_ae_obj_id__event: event.delete_ae_obj_id__event,

View File

@@ -253,7 +253,7 @@
);
$idaa_prom.load__event_obj_qry = events_func
.qry_ae_obj_li__event_v2({
.search__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $ae_loc.account_id,