Cleaning up and removing old legacy code and files
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { api } from '$lib/api/api';
|
||||
import { get_ae_obj_li_for_obj_id_crud_v2 } from '$lib/ae_api/api_get__crud_obj_li_v2';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
@@ -490,10 +489,10 @@ export async function update_ae_obj__event({
|
||||
// Updated 2026-01-21
|
||||
/**
|
||||
* Unified Search for Events (V3 API)
|
||||
*
|
||||
*
|
||||
* STRATEGY: Hybrid Search/Filter
|
||||
* 1. Server-side (V3 Search): Used for text search (qry_str) to reduce payload.
|
||||
* 2. Client-side (Filter Layer): Handles all other filters (Type, Location, Person)
|
||||
* 2. Client-side (Filter Layer): Handles all other filters (Type, Location, Person)
|
||||
* to ensure correct inclusive OR logic and stable ID matching.
|
||||
*/
|
||||
export async function search__event({
|
||||
@@ -548,13 +547,13 @@ export async function search__event({
|
||||
params['lk_qry'] = { 'default_qry_str': qry_str.trim() };
|
||||
|
||||
if (for_obj_id) {
|
||||
// V3 Standard: Use random string ID for body filters.
|
||||
// V3 Standard: Use random string ID for body filters.
|
||||
// The API resolves this to the integer column automatically.
|
||||
search_query.and.push({ field: `${for_obj_type}_id_random`, op: 'eq', value: for_obj_id });
|
||||
}
|
||||
|
||||
// NOTE: We do NOT push 'physical' and 'virtual' to the server-side query here.
|
||||
// The V3 Search API uses AND logic for the body, which would exclude
|
||||
// The V3 Search API uses AND logic for the body, which would exclude
|
||||
// meetings that are only physical or only virtual if both filters are active.
|
||||
// We handle this in the Client-side Filter Layer below for correct OR logic.
|
||||
|
||||
@@ -671,131 +670,131 @@ export const qry_ae_obj_li__event = search__event;
|
||||
* This is isolated to prevent V3 migration bugs from affecting Recovery Meetings.
|
||||
*/
|
||||
// Updated 2026-01-20
|
||||
export async function qry_ae_obj_li__event_v2({
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_str,
|
||||
qry_person_id = null,
|
||||
qry_conference = null,
|
||||
qry_physical = null,
|
||||
qry_virtual = null,
|
||||
qry_type = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
view = 'default',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = { start_datetime: 'DESC' } as const,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id: string;
|
||||
qry_str?: string;
|
||||
qry_person_id?: string | null;
|
||||
qry_conference?: boolean | null;
|
||||
qry_physical?: boolean | null;
|
||||
qry_virtual?: boolean | null;
|
||||
qry_type?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: Record<string, 'ASC' | 'DESC'>;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) console.log('*** qry_ae_obj_li__event_v2() ***');
|
||||
// export async function qry_ae_obj_li__event_v2({
|
||||
// api_cfg,
|
||||
// for_obj_type = 'account',
|
||||
// for_obj_id,
|
||||
// qry_str,
|
||||
// qry_person_id = null,
|
||||
// qry_conference = null,
|
||||
// qry_physical = null,
|
||||
// qry_virtual = null,
|
||||
// qry_type = null,
|
||||
// enabled = 'enabled',
|
||||
// hidden = 'not_hidden',
|
||||
// view = 'default',
|
||||
// limit = 99,
|
||||
// offset = 0,
|
||||
// order_by_li = { start_datetime: 'DESC' } as const,
|
||||
// try_cache = true,
|
||||
// log_lvl = 0
|
||||
// }: {
|
||||
// api_cfg: any;
|
||||
// for_obj_type?: string;
|
||||
// for_obj_id: string;
|
||||
// qry_str?: string;
|
||||
// qry_person_id?: string | null;
|
||||
// qry_conference?: boolean | null;
|
||||
// qry_physical?: boolean | null;
|
||||
// qry_virtual?: boolean | null;
|
||||
// qry_type?: string | null;
|
||||
// enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
// hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
// view?: string;
|
||||
// limit?: number;
|
||||
// offset?: number;
|
||||
// order_by_li?: Record<string, 'ASC' | 'DESC'>;
|
||||
// try_cache?: boolean;
|
||||
// log_lvl?: number;
|
||||
// }) {
|
||||
// if (log_lvl) console.log('*** qry_ae_obj_li__event_v2() ***');
|
||||
|
||||
const params_json: any = { qry: { and: [] } };
|
||||
// const params_json: any = { qry: { and: [] } };
|
||||
|
||||
if (qry_str) {
|
||||
// Use default_qry_str for searching as requested
|
||||
params_json.qry.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str}%` });
|
||||
}
|
||||
// if (qry_str) {
|
||||
// // Use default_qry_str for searching as requested
|
||||
// params_json.qry.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str}%` });
|
||||
// }
|
||||
|
||||
const result_li = await get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled,
|
||||
hidden,
|
||||
limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
params_json,
|
||||
log_lvl
|
||||
});
|
||||
// const result_li = await get_ae_obj_li_for_obj_id_crud_v2({
|
||||
// api_cfg,
|
||||
// obj_type: 'event',
|
||||
// for_obj_type,
|
||||
// for_obj_id,
|
||||
// enabled,
|
||||
// hidden,
|
||||
// limit,
|
||||
// offset,
|
||||
// order_by_li,
|
||||
// params_json,
|
||||
// log_lvl
|
||||
// });
|
||||
|
||||
if (!result_li) return [];
|
||||
// if (!result_li) return [];
|
||||
|
||||
const processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: result_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
// const processed_obj_li = await process_ae_obj__event_props({
|
||||
// obj_li: result_li,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'event',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
// if (try_cache) {
|
||||
// await db_save_ae_obj_li__ae_obj({
|
||||
// db_instance: db_events,
|
||||
// table_name: 'event',
|
||||
// obj_li: processed_obj_li,
|
||||
// properties_to_save: properties_to_save,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
// }
|
||||
|
||||
// Client-side Filter Layer
|
||||
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;
|
||||
}
|
||||
// // Client-side Filter Layer
|
||||
// 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';
|
||||
// // 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';
|
||||
|
||||
let match = false;
|
||||
if (qry_physical === true && ev_physical) match = true;
|
||||
if (qry_virtual === true && ev_virtual) match = true;
|
||||
// let match = false;
|
||||
// if (qry_physical === true && ev_physical) match = true;
|
||||
// if (qry_virtual === true && ev_virtual) match = true;
|
||||
|
||||
if (!match) return false;
|
||||
}
|
||||
// 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 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 = (
|
||||
ev.external_person_id === qry_person_id ||
|
||||
ev.poc_person_id === qry_person_id ||
|
||||
ev.poc_person_id_random === qry_person_id ||
|
||||
ev.poc_event_person_id === qry_person_id ||
|
||||
ev.poc_event_person_id_random === qry_person_id
|
||||
);
|
||||
if (!match) return false;
|
||||
}
|
||||
// // Handle person ID filter
|
||||
// if (qry_person_id) {
|
||||
// const match = (
|
||||
// ev.external_person_id === qry_person_id ||
|
||||
// ev.poc_person_id === qry_person_id ||
|
||||
// ev.poc_person_id_random === qry_person_id ||
|
||||
// ev.poc_event_person_id === qry_person_id ||
|
||||
// ev.poc_event_person_id_random === qry_person_id
|
||||
// );
|
||||
// if (!match) return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
});
|
||||
// return true;
|
||||
// });
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Filter results (V2): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
|
||||
}
|
||||
// if (log_lvl) {
|
||||
// console.log(`Filter results (V2): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
|
||||
// }
|
||||
|
||||
return filtered_obj_li.slice(0, limit);
|
||||
}
|
||||
// return filtered_obj_li.slice(0, limit);
|
||||
// }
|
||||
|
||||
// Updated 2026-03-10
|
||||
export const properties_to_save = [
|
||||
|
||||
@@ -41,7 +41,7 @@ const export_obj = {
|
||||
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,
|
||||
// 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,
|
||||
update_ae_obj__event: event.update_ae_obj__event,
|
||||
|
||||
Reference in New Issue
Block a user