Working on making the LIKE query work correctly.
This commit is contained in:
@@ -169,7 +169,10 @@ 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, external_event_id, params={}, try_cache=true}) {
|
||||
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
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
@@ -187,6 +190,25 @@ async function handle_search__event_badge({api_cfg, event_id, type_code=null, fu
|
||||
};
|
||||
}
|
||||
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// Old Python version that needs to be in JS
|
||||
// # Strip (left right) whitespace then commas then semicolons
|
||||
// query_str = query_str.strip().strip(',').strip(';')
|
||||
// # Replace commas, semicolons, and then spaces with %
|
||||
// query_str_like = query_str.replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%')
|
||||
// # data['query_str'] = f'%{query_str}%'
|
||||
// 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);
|
||||
|
||||
params_json['like_qry'] = {
|
||||
'default_qry_str': like_search_qry_str_new,
|
||||
};
|
||||
}
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
if (external_event_id) {
|
||||
params_json['and_qry']['external_event_id'] = external_event_id;
|
||||
|
||||
@@ -153,7 +153,14 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||
|
||||
$events_sess.status_qry__search = 'loading';
|
||||
|
||||
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, external_event_id: $events_loc.badges.default__external_registration_id})
|
||||
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
|
||||
})
|
||||
.then(function (search_results) {
|
||||
$events_slct.badge_obj_li = search_results;
|
||||
console.log(search_results);
|
||||
@@ -168,7 +175,14 @@ $: if ($events_trigger == 'load__event_badge_obj_li' && $events_slct.event_id) {
|
||||
|
||||
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, external_event_id: $events_loc.badges.default__external_registration_id})
|
||||
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
|
||||
})
|
||||
.then(function (search_results) {
|
||||
$events_slct.badge_obj_li = search_results;
|
||||
console.log(search_results);
|
||||
|
||||
Reference in New Issue
Block a user