The search is working better now. Also better and less debug logging.

This commit is contained in:
Scott Idem
2024-10-01 18:09:27 -04:00
parent fad58bf26f
commit 1c1845280b
5 changed files with 93 additions and 66 deletions

View File

@@ -54,7 +54,8 @@ $: lq_new__event_obj_li = liveQuery(async () => {
let link_to_id: string = $slct.account_id;
console.log(`link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
if (event_id_random_li?.length) {
// Check if event_id_random_li is an array and not undefined
if (event_id_random_li) {
console.log(`Trying bulkGet:`, event_id_random_li);
let results = await db_events.events
.bulkGet(event_id_random_li);

View File

@@ -40,20 +40,21 @@ $: if (ae_trigger == 'load__event_obj_li') {
setTimeout(() => {
console.log("Delayed for X second.");
// ae_trigger = null;
handle_search__event({lk_search_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
handle_qry__event({ft_qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
}, 250);
} else {
console.log('*** $idaa_sess.recovery_meetings.qry_status != loading ***');
// ae_trigger = null;
handle_search__event({lk_search_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
handle_qry__event({ft_qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
}
}
async function handle_search__event(
async function handle_qry__event(
{
ft_search_str = '',
lk_search_str = '',
and_lk_location_name = '',
ft_qry_str = '',
and_physical = $idaa_loc.recovery_meetings.qry__physical,
and_virtual = $idaa_loc.recovery_meetings.qry__virtual,
and_type = $idaa_loc.recovery_meetings.qry__type,
search_delay = 0,
max_tries = 5,
params = {
@@ -61,12 +62,13 @@ async function handle_search__event(
'qry__hidden': $idaa_loc.recovery_meetings.qry__hidden ?? 'not_hidden',
'qry__limit': $idaa_loc.recovery_meetings.qry__limit ?? 35,
},
try_cache=false,
log_lvl=1,
try_cache = false,
log_lvl = 1,
}: {
ft_search_str?: string,
lk_search_str?: string,
and_lk_location_name?: string,
ft_qry_str?: string,
and_physical?: null|boolean,
and_virtual?: null|boolean,
and_type?: null|string,
search_delay?: number, // In milliseconds
max_tries?: number,
params?: key_val,
@@ -74,19 +76,19 @@ async function handle_search__event(
log_lvl?: number,
}
) {
console.log('handle_search__event()');
console.log('handle_qry__event()');
if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != 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.
$idaa_sess.recovery_meetings.status_qry__last_request_str = lk_search_str;
$idaa_sess.recovery_meetings.status_qry__last_request_str = ft_qry_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 = 2;
log_lvl = 1;
let count = 0;
let request_loop = setInterval(() => {
@@ -103,30 +105,35 @@ async function handle_search__event(
let random_delay = Math.floor(Math.random() * 25);
search_delay += 25+random_delay;
console.log(`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == loading wait *** search_delay=${search_delay}`);
// $idaa_sess.status_qry__last_request_str = lk_search_str;
// $idaa_sess.status_qry__last_request_str = ft_qry_str;
} else {
console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != loading ***');
$idaa_sess.recovery_meetings.qry__status = 'loading';
search_submit_results = events_func.load_ae_obj_li__event({
(and_physical) ?? null;
(and_virtual) ?? null;
(and_type) ?? null;
// if (and_type) and_type = and_type;
// if (!and_type) {
// and_type = null;
// }
console.log(`TEST - and_physical: ${and_physical}; and_virtual: ${and_virtual}; and_type: ${and_type}; ft_qry_str: ${ft_qry_str}; params:`, params);
search_submit_results = events_func.qry_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $ae_loc.account_id,
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'},
qry_conference: false,
qry_str: lk_search_str,
// type_code: type_code,
// qry__fulltext_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,
// external_event_id: $idaa_loc.recovery_meetings.default__external_registration_id,
// location_name: and_lk_location_name,
qry_physical: and_physical,
qry_virtual: and_virtual,
qry_type: and_type,
qry_str: ft_qry_str,
params: params,
try_cache: try_cache,
log_lvl: 0,
log_lvl: log_lvl,
})
.then(function (search_results) {
// Processing the results from the search.