The sorting now works and some missing fields were added.

This commit is contained in:
Scott Idem
2026-01-05 18:29:41 -05:00
parent 17589596bc
commit bb6b3b7352
3 changed files with 8 additions and 170 deletions

View File

@@ -12,7 +12,7 @@ const ae_promises: key_val = {};
export async function load_ae_obj_id__event_badge({
api_cfg,
event_badge_id,
view = 'default',
view = 'base',
inc_template = true,
try_cache = true,
log_lvl = 0
@@ -431,7 +431,7 @@ export async function search__event_badge({
external_event_id = null,
enabled = 'enabled',
hidden = 'not_hidden',
view = 'default',
view = 'base',
limit = 25,
offset = 0,
order_by_li = {

View File

@@ -176,6 +176,10 @@ export interface Badge {
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
print_count?: null | number;
print_first_datetime?: null | Date | string;
print_last_datetime?: null | Date | string;
// Additional fields for convenience (database views)
person_external_id?: null | string; // This may be semi-random or unique only withing the account.
person_external_sys_id?: null | string; // Generated by an external system. Ideally this should be something like a UUID. It may be the same as the external_id if nothing given.
@@ -816,6 +820,7 @@ export class MySubClassedDexie extends Dexie {
default_qry_string,
alert,
tmp_sort_1, tmp_sort_2,
print_count, print_first_datetime, print_last_datetime,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
badge_template: `

View File

@@ -194,7 +194,7 @@
affiliations_qry_str: qry_affiliations,
order_by_li: computed_order_by_li,
limit: search_limit,
log_lvl: log_lvl
log_lvl: 2
})
.then(function (search_results) {
search_status = 'processing';
@@ -224,173 +224,6 @@
}
});
// function process_search_string(search_str: string) {
// if (log_lvl) {
// console.log(`process_search_string() search_str=${search_str}`);
// }
// if (search_str?.length) {
// // console.log(`*** Search string length: ${search_str.length} ***`);
// } else {
// // console.log(`*** Search string is empty ***`);
// }
// // let type_code = $events_sess.badges.search_badge_type_code;
// // let search_str = $events_loc.badges.fulltext_search_qry_str.trim();
// let search_method = 'lk'; // 'ft', 'lk', 'eq'
// let ft_search_str_new = '';
// let lk_search_str_new = '';
// if (search_method == 'ft') {
// // Add quotes around the search string to make it an exact match.
// ft_search_str_new = `${search_str}`;
// // ft_search_str_new = `"${search_str}"`;
// } else if (search_method == 'lk') {
// if (search_str == null) {
// search_str = '';
// }
// // Add a wildcard to the search string to make it a like match.
// lk_search_str_new = search_str.trim().replace(',', ' ').replace(';', ' ').replaceAll(' ', '%').replaceAll(' ', '%');
// lk_search_str_new = `%${lk_search_str_new}%`;
// }
// if (log_lvl) {
// // console.log(`*** Search method: ${search_method} ***`);
// console.log(`*** Search string: ${search_str} ***`);
// // console.log(`*** Fulltext search string: ${ft_search_str_new} ***`);
// // console.log(`*** Like search string: ${lk_search_str_new} ***`);
// }
// let type_code = '';
// if ($events_sess.badges.type_code_qry_str?.length) {
// type_code = $events_sess.badges.type_code_qry_str;
// console.log(`Type code: ${type_code}`);
// }
// handle_search__event_badge({
// ft_search_str: ft_search_str_new,
// lk_search_str: lk_search_str_new,
// and_lk_type_code: type_code,
// // fulltext_search_qry_str: ft_search_str_new,
// // ft_presenter_search_qry_str: null,
// // like_search_qry_str: lk_search_str_new,
// // like_presentation_search_qry_str: lk_search_str_new,
// // like_presenter_search_qry_str: lk_search_str_new,
// // params: params,
// try_cache: true,
// log_lvl: log_lvl,
// });
// }
async function handle_search__event_badge({
ft_search_str = '',
lk_search_str = '',
and_lk_type_code = '',
search_delay = 0,
max_tries = 5,
enabled = $events_loc.badges.qry_enabled ?? 'enabled',
hidden = $events_loc.badges.qry_hidden ?? 'not_hidden',
limit = $events_loc.badges.qry_limit__badges ?? 35,
try_cache = true,
log_lvl = 0
}: {
ft_search_str?: string;
lk_search_str?: string;
and_lk_type_code?: string;
search_delay?: number; // In milliseconds
max_tries?: number;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log('handle_search__event_badge()');
}
if (
$events_sess.badges?.status_qry__search != null &&
$events_sess.badges?.status_qry__search != 'done'
) {
// WARNING: This is a temporary fix for the search string. It needs to be fixed in the future. Using lk_search_str for now.
$events_sess.badges.status_qry__last_request_str = lk_search_str;
// We want to delay the initial search request to give the previous search request to finish.
let random_delay = Math.floor(Math.random() * 50);
search_delay += 50 + random_delay;
}
// log_lvl = 1;
let count = 0;
let request_loop = setInterval(() => {
count++;
if (log_lvl) {
console.log(
`*** TEST SEARCH - Search delay: ${search_delay} *** loop count=${count}`
);
}
if (count >= max_tries) {
console.log('*** TEST SEARCH - Max tries reached ***');
clearInterval(request_loop);
}
if (
$events_sess.badges?.status_qry__search != null &&
$events_sess.badges?.status_qry__search != 'done'
) {
let random_delay = Math.floor(Math.random() * 25);
search_delay += 25 + random_delay;
console.log(
`*** TEST SEARCH - $events_sess.badges.status_qry__search == loading wait *** search_delay=${search_delay}`
);
// $events_sess.status_qry__last_request_str = lk_search_str;
} else {
// console.log('*** TEST SEARCH - $events_sess.badges.status_qry__search != loading ***');
ae_triggers.event_badge_qry = 'loading_search_results';
$events_sess.badges.status_qry__search = 'loading';
event_badge_id_li = []; // Resetting this seems to help trigger the new results to show correctly???
search_submit_results = events_func
.search__event_badge({
api_cfg: $ae_api,
event_id: $events_slct.event_id,
// type_code: type_code,
fulltext_search_qry_str: ft_search_str,
// ft_presenter_search_qry_str: null,
like_search_qry_str: lk_search_str,
// like_presentation_search_qry_str: lk_search_str,
// like_presenter_search_qry_str: lk_search_str,
// like_poc_name_qry_str: lk_search_str,
// external_event_id: $events_loc.badges.default__external_registration_id,
// location_name: and_lk_location_name,
// enabled: enabled,
// hidden: hidden,
// limit: limit,
// try_cache: try_cache,
log_lvl: log_lvl
})
.then(function (search_results) {
// Processing the results from the search.
ae_triggers.event_badge_qry = 'process_search_results';
$events_sess.badges.status_qry__search = 'processing';
$events_slct.event_badge_obj_li = search_results;
})
.finally(() => {
// Finally done with the search.
ae_triggers.event_badge_qry = 'search_done';
$events_sess.badges.status_qry__search = 'done';
});
clearInterval(request_loop);
}
}, search_delay);
}
function handle_qr_scan_result(event: CustomEvent) {
console.log('*** handle_qr_scan_result() ***');