Now with search on presenter's name and email

This commit is contained in:
Scott Idem
2024-06-21 15:08:58 -04:00
parent 87b4f22bb1
commit e5cff89acb
2 changed files with 61 additions and 26 deletions

View File

@@ -355,18 +355,22 @@ async function handle_search__event_session(
api_cfg,
event_id,
fulltext_search_qry_str,
ft_presenter_search_qry_str,
like_search_qry_str=null,
// session_type_code=null,
like_presenter_search_qry_str=null,
params={},
try_cache=true
try_cache=true,
log_lvl=0
}: {
api_cfg: any,
event_id: any,
fulltext_search_qry_str: any,
like_search_qry_str: any,
// session_type_code: any,
fulltext_search_qry_str: null|string,
ft_presenter_search_qry_str: null|string,
like_search_qry_str: null|string,
like_presenter_search_qry_str: null|string,
params: any,
try_cache: boolean
try_cache: boolean,
log_lvl: null|number
}
) {
console.log(`*** handle_search__event_session() *** event_id=${event_id}`);
@@ -383,16 +387,37 @@ async function handle_search__event_session(
return false; // Returning false instead of [] because no search was performed.
}
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
params_json['ft_qry'] = {
'default_qry_str': fulltext_search_qry_str,
};
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
params_json['ft_qry'] = {};
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
}
if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) {
params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str;
}
}
if (like_search_qry_str && like_search_qry_str.length > 2) {
params_json['and_like'] = {
'default_qry_str': like_search_qry_str,
};
// Use the AND (AND LIKE) query
// if (like_search_qry_str || like_presenter_search_qry_str) {
// params_json['and_like'] = {};
// if (like_search_qry_str && like_search_qry_str.length > 2) {
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
// }
// if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
// params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
// }
// }
// Use the AND (OR LIKE) query
if (like_search_qry_str || like_presenter_search_qry_str) {
params_json['or_like'] = {};
if (like_search_qry_str && like_search_qry_str.length > 2) {
params_json['or_like']['default_qry_str'] = like_search_qry_str;
}
if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
}
}
params_json['and_qry'] = {};
@@ -408,15 +433,16 @@ async function handle_search__event_session(
obj_type: 'event_session',
for_obj_type: 'event',
for_obj_id: event_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
use_alt_table: true, // NOTE: We want to use the alt table for session searching
use_alt_base: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params
params: params,
log_lvl: log_lvl
})
.then(function (event_session_obj_li_get_result) {
if (event_session_obj_li_get_result) {
@@ -831,7 +857,8 @@ async function handle_search__event_badge(
like_search_qry_str=null,
external_event_id,
params={},
try_cache=true
try_cache=true,
log_lvl=0
}: {
api_cfg: any,
event_id: any,
@@ -840,7 +867,8 @@ async function handle_search__event_badge(
like_search_qry_str: any,
external_event_id: any,
params: any,
try_cache: boolean
try_cache: boolean,
log_lvl: number
}
) {
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
@@ -911,7 +939,7 @@ async function handle_search__event_badge(
offset: offset,
params_json: params_json,
params: params,
log_lvl: 1
log_lvl: log_lvl
})
.then(function (badge_obj_li_get_result) {
// console.log('Badge list:', badge_obj_li_get_result);

View File

@@ -115,10 +115,11 @@ $: if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id)
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}`;
// ft_search_str_new = `"${search_str}"`;
} else if (search_method == 'lk') {
// Add a wildcard to the search string to make it a like match.
lk_search_str_new = search_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%');
lk_search_str_new = search_str.trim().replace(',', ' ').replace(';', ' ').replaceAll(' ', '%').replaceAll(' ', '%');
lk_search_str_new = `%${lk_search_str_new}%`;
}
console.log(`"${search_str}"`);
@@ -156,10 +157,13 @@ $: if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id)
event_id: $events_slct.event_id,
// 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_presenter_search_qry_str: lk_search_str_new,
// external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
params: params,
try_cache: false
try_cache: false,
log_lvl: 1,
})
.then(function (search_results) {
$events_slct.session_obj_li = search_results;
@@ -177,10 +181,13 @@ $: if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id)
event_id: $events_slct.event_id,
// 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_presenter_search_qry_str: lk_search_str_new,
// external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
params: params,
try_cache: false
try_cache: false,
log_lvl: 1,
})
.then(function (search_results) {
$events_slct.session_obj_li = search_results;
@@ -306,10 +313,10 @@ $: if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id)
<td>
<a
href="/events_pres_mgmt/session/{session_obj.event_session_id_random}"
class="btn btn-md variant-ghost-secondary hover:variant-filled-secondary w-full"
class="btn btn-md variant-ghost-secondary hover:variant-filled-secondary min-w-full max-w-md"
>
<span class="fas fa-eye mx-1"></span>
<span class="grow">
<span class="grow overflow-x-scroll">
<strong>{session_obj.name}</strong>
</span>
</a>