Working on making the LIKE query work correctly.

This commit is contained in:
2024-04-07 14:06:31 -04:00
parent 02af46a48f
commit bde3229270
2 changed files with 39 additions and 3 deletions

View File

@@ -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;