The AND LIKE query is now working!
This commit is contained in:
@@ -171,7 +171,16 @@ async function handle_load_ae_obj_li__badge(
|
||||
|
||||
async function handle_search__event_badge(
|
||||
{api_cfg, event_id, type_code=null, fulltext_search_qry_str, like_search_qry_str=null, external_event_id, params={}, try_cache=true
|
||||
}
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
type_code: any,
|
||||
fulltext_search_qry_str: any,
|
||||
like_search_qry_str: any,
|
||||
external_event_id: any,
|
||||
params: any,
|
||||
try_cache: boolean
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
|
||||
|
||||
@@ -200,12 +209,12 @@ async function handle_search__event_badge(
|
||||
// log.debug(query_str_like)
|
||||
// data['query_str'] = f'%{query_str_like}%'
|
||||
|
||||
let like_search_qry_str_new = like_search_qry_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%');
|
||||
like_search_qry_str_new = `%${like_search_qry_str_new}%`;
|
||||
console.log('like_search_qry_str_new:', like_search_qry_str_new);
|
||||
// let like_search_qry_str_new = like_search_qry_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%');
|
||||
// like_search_qry_str_new = `%${like_search_qry_str_new}%`;
|
||||
// console.log('like_search_qry_str_new:', like_search_qry_str_new);
|
||||
|
||||
params_json['like_qry'] = {
|
||||
'default_qry_str': like_search_qry_str_new,
|
||||
params_json['and_like'] = {
|
||||
'default_qry_str': like_search_qry_str,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -842,6 +842,7 @@ export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_
|
||||
// NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
|
||||
// Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
|
||||
console.log('JSON Object:', params_json);
|
||||
console.log(JSON.stringify(params_json));
|
||||
// NOTE: "jp" stands for "JSON Params"
|
||||
params['jp'] = encodeURIComponent(JSON.stringify(params_json));
|
||||
if (params['jp'].length > 2083) {
|
||||
|
||||
@@ -140,10 +140,25 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||
}
|
||||
|
||||
let type_code = $events_sess.badges.search_badge_type_code;
|
||||
|
||||
let search_str = $events_sess.badges.fulltext_search_qry_str.trim();
|
||||
// Add quotes around the search string to make it an exact match.
|
||||
search_str = `"${search_str}"`;
|
||||
console.log(search_str);
|
||||
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}"`;
|
||||
} 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 = `%${lk_search_str_new}%`;
|
||||
}
|
||||
console.log(`"${search_str}"`);
|
||||
|
||||
let params = {
|
||||
'qry__limit': 35,
|
||||
}
|
||||
|
||||
if ($events_sess.status_qry__search == 'loading') {
|
||||
console.log('*** $events_sess.status_qry__search == loading ***');
|
||||
@@ -157,9 +172,11 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||
api_cfg: $ae_api,
|
||||
event_id: $events_slct.event_id,
|
||||
type_code: type_code,
|
||||
fulltext_search_qry_str: search_str,
|
||||
like_search_qry_str: '',
|
||||
external_event_id: $events_loc.badges.default__external_registration_id
|
||||
fulltext_search_qry_str: ft_search_str_new,
|
||||
like_search_qry_str: lk_search_str_new,
|
||||
external_event_id: $events_loc.badges.default__external_registration_id,
|
||||
params: params,
|
||||
try_cache: false
|
||||
})
|
||||
.then(function (search_results) {
|
||||
$events_slct.badge_obj_li = search_results;
|
||||
@@ -172,16 +189,15 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||
|
||||
$events_sess.status_qry__search = 'loading';
|
||||
|
||||
|
||||
console.log(search_str);
|
||||
|
||||
search_submit_results = events_func.handle_search__event_badge({
|
||||
api_cfg: $ae_api,
|
||||
event_id: $events_slct.event_id,
|
||||
type_code: type_code,
|
||||
fulltext_search_qry_str: search_str,
|
||||
like_search_qry_str: '',
|
||||
external_event_id: $events_loc.badges.default__external_registration_id
|
||||
fulltext_search_qry_str: ft_search_str_new,
|
||||
like_search_qry_str: lk_search_str_new,
|
||||
external_event_id: $events_loc.badges.default__external_registration_id,
|
||||
params: params,
|
||||
try_cache: false
|
||||
})
|
||||
.then(function (search_results) {
|
||||
$events_slct.badge_obj_li = search_results;
|
||||
|
||||
Reference in New Issue
Block a user