Last round of prettier: npx prettier --write src/

This commit is contained in:
Scott Idem
2026-03-24 13:27:40 -04:00
parent 23d25bf65a
commit a8f3c29b9f
146 changed files with 13201 additions and 9277 deletions

View File

@@ -35,29 +35,36 @@ export async function load_ae_obj_id__event_badge({
log_lvl?: number;
}): Promise<ae_EventBadge | null> {
if (log_lvl) {
console.log(`*** load_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`);
console.log(
`*** load_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`
);
}
try {
ae_promises.load__event_badge_obj = await api
.get_ae_obj({
api_cfg,
obj_type: 'event_badge',
obj_id: event_badge_id,
view,
log_lvl
});
ae_promises.load__event_badge_obj = await api.get_ae_obj({
api_cfg,
obj_type: 'event_badge',
obj_id: event_badge_id,
view,
log_lvl
});
if (ae_promises.load__event_badge_obj) {
if (try_cache) {
// In theory we should be able to use the event_id found in the Badge load object. 2026-02-04
// This keeps coming up as undefined: ae_promises.load__event_badge_obj.event_id
if (log_lvl) console.log(`Saving to local cache... Event ID: ${event_id} or ${ae_promises.load__event_badge_obj.event_id}`);
const processed_obj_li = await process_ae_obj__event_badge_props({
obj_li: [ae_promises.load__event_badge_obj],
event_id: event_id || ae_promises.load__event_badge_obj.event_id,
log_lvl
});
if (log_lvl)
console.log(
`Saving to local cache... Event ID: ${event_id} or ${ae_promises.load__event_badge_obj.event_id}`
);
const processed_obj_li =
await process_ae_obj__event_badge_props({
obj_li: [ae_promises.load__event_badge_obj],
event_id:
event_id ||
ae_promises.load__event_badge_obj.event_id,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'badge',
@@ -71,15 +78,21 @@ export async function load_ae_obj_id__event_badge({
} else {
console.log('No results returned from API.');
if (try_cache) {
if (log_lvl) console.log('Attempting to load from local cache...');
ae_promises.load__event_badge_obj = await db_events.badge.get(event_badge_id);
if (log_lvl)
console.log('Attempting to load from local cache...');
ae_promises.load__event_badge_obj =
await db_events.badge.get(event_badge_id);
}
}
} catch (error: any) {
console.log('API request failed.', error);
if (try_cache) {
if (log_lvl) console.log('Attempting to load from local cache after error...');
ae_promises.load__event_badge_obj = await db_events.badge.get(event_badge_id);
if (log_lvl)
console.log(
'Attempting to load from local cache after error...'
);
ae_promises.load__event_badge_obj =
await db_events.badge.get(event_badge_id);
} else {
ae_promises.load__event_badge_obj = null;
}
@@ -87,14 +100,16 @@ export async function load_ae_obj_id__event_badge({
if (inc_template && ae_promises.load__event_badge_obj) {
// Load the templates for the event badge
const current_template_id = ae_promises.load__event_badge_obj.event_badge_template_id;
const current_template_id =
ae_promises.load__event_badge_obj.event_badge_template_id;
if (current_template_id) {
ae_promises.load__event_badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
event_badge_template_id: current_template_id,
try_cache: try_cache,
log_lvl: log_lvl
});
ae_promises.load__event_badge_obj.event_badge_template =
await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
event_badge_template_id: current_template_id,
try_cache: try_cache,
log_lvl: log_lvl
});
}
}
@@ -111,7 +126,12 @@ export async function load_ae_obj_li__event_badge({
view = 'default',
limit = 99,
offset = 0,
order_by_li = { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
order_by_li = {
priority: 'DESC',
sort: 'DESC',
updated_on: 'DESC',
created_on: 'DESC'
},
params = {},
try_cache = true,
log_lvl = 0
@@ -130,32 +150,34 @@ export async function load_ae_obj_li__event_badge({
log_lvl?: number;
}): Promise<ae_EventBadge[]> {
if (log_lvl) {
console.log(`*** load_ae_obj_li__event_badge() *** event_id=${event_id}`);
console.log(
`*** load_ae_obj_li__event_badge() *** event_id=${event_id}`
);
}
try {
ae_promises.load__event_badge_obj_li = await api
.get_ae_obj_li({
api_cfg,
obj_type: 'event_badge',
for_obj_type: 'event',
for_obj_id: event_id,
enabled: enabled,
hidden: hidden,
view: view,
order_by_li: order_by_li,
limit: limit,
offset: offset,
log_lvl: log_lvl
});
ae_promises.load__event_badge_obj_li = await api.get_ae_obj_li({
api_cfg,
obj_type: 'event_badge',
for_obj_type: 'event',
for_obj_id: event_id,
enabled: enabled,
hidden: hidden,
view: view,
order_by_li: order_by_li,
limit: limit,
offset: offset,
log_lvl: log_lvl
});
if (ae_promises.load__event_badge_obj_li) {
if (try_cache) {
const processed_obj_li = await process_ae_obj__event_badge_props({
obj_li: ae_promises.load__event_badge_obj_li,
event_id,
log_lvl
});
const processed_obj_li =
await process_ae_obj__event_badge_props({
obj_li: ae_promises.load__event_badge_obj_li,
event_id,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'badge',
@@ -169,9 +191,11 @@ export async function load_ae_obj_li__event_badge({
} else {
console.log('No results returned from API.');
if (try_cache) {
if (log_lvl) console.log('Attempting to load from local cache...');
if (log_lvl)
console.log('Attempting to load from local cache...');
ae_promises.load__event_badge_obj_li = await db_events.badge
.where('event_id').equals(event_id)
.where('event_id')
.equals(event_id)
.toArray();
} else {
ae_promises.load__event_badge_obj_li = [];
@@ -180,9 +204,13 @@ export async function load_ae_obj_li__event_badge({
} catch (error: any) {
console.log('API request failed.', error);
if (try_cache) {
if (log_lvl) console.log('Attempting to load from local cache after error...');
if (log_lvl)
console.log(
'Attempting to load from local cache after error...'
);
ae_promises.load__event_badge_obj_li = await db_events.badge
.where('event_id').equals(event_id)
.where('event_id')
.equals(event_id)
.toArray();
} else {
ae_promises.load__event_badge_obj_li = [];
@@ -193,12 +221,13 @@ export async function load_ae_obj_li__event_badge({
for (const badge_obj of ae_promises.load__event_badge_obj_li) {
const current_template_id = badge_obj.event_badge_template_id;
if (current_template_id) {
badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
event_badge_template_id: current_template_id,
try_cache: try_cache,
log_lvl: log_lvl
});
badge_obj.event_badge_template =
await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
event_badge_template_id: current_template_id,
try_cache: try_cache,
log_lvl: log_lvl
});
}
}
}
@@ -223,7 +252,9 @@ export async function create_ae_obj__event_badge({
log_lvl?: number;
}): Promise<ae_EventBadge | null> {
if (log_lvl) {
console.log(`*** create_ae_obj__event_badge() *** event_id=${event_id}`);
console.log(
`*** create_ae_obj__event_badge() *** event_id=${event_id}`
);
}
const result = await api.create_nested_obj({
@@ -275,7 +306,9 @@ export async function delete_ae_obj_id__event_badge({
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`);
console.log(
`*** delete_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`
);
}
const result = await api.delete_nested_ae_obj({
@@ -315,7 +348,9 @@ export async function update_ae_obj__event_badge({
log_lvl?: number;
}): Promise<ae_EventBadge | null> {
if (log_lvl) {
console.log(`*** update_ae_obj__event_badge() *** event_badge_id=${event_badge_id}`);
console.log(
`*** update_ae_obj__event_badge() *** event_badge_id=${event_badge_id}`
);
}
const result = await api.update_nested_obj({
@@ -391,7 +426,9 @@ export async function search__event_badge({
log_lvl?: number;
}): Promise<ae_EventBadge[] | false> {
if (log_lvl) {
console.log(`*** search__event_badge() *** event_id=${event_id} ft=${fulltext_search_qry_str}`);
console.log(
`*** search__event_badge() *** event_id=${event_id} ft=${fulltext_search_qry_str}`
);
}
const search_query: any = {
@@ -406,15 +443,23 @@ export async function search__event_badge({
// Multi-word support: Split query by spaces and search for all words (AND logic)
if (fulltext_search_qry_str && fulltext_search_qry_str.trim().length > 0) {
const qry = fulltext_search_qry_str.trim();
const words = qry.split(/\s+/).filter(w => w.length > 0);
const words = qry.split(/\s+/).filter((w) => w.length > 0);
if (words.length === 1) {
// Single word: use simple LIKE
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${words[0]}%` });
search_query.and.push({
field: 'default_qry_str',
op: 'like',
value: `%${words[0]}%`
});
} else if (words.length > 1) {
// Multiple words: each word must match (AND logic)
for (const word of words) {
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${word}%` });
search_query.and.push({
field: 'default_qry_str',
op: 'like',
value: `%${word}%`
});
}
}
@@ -424,7 +469,11 @@ export async function search__event_badge({
if (affiliations_qry_str && affiliations_qry_str.trim().length > 0) {
const qry = affiliations_qry_str.trim();
search_query.and.push({ field: 'affiliations', op: 'like', value: `%${qry}%` });
search_query.and.push({
field: 'affiliations',
op: 'like',
value: `%${qry}%`
});
params['lk_qry'] = params['lk_qry'] || {};
params['lk_qry']['affiliations'] = qry;
}
@@ -435,11 +484,19 @@ export async function search__event_badge({
}
if (external_event_id) {
search_query.and.push({ field: 'external_event_id', op: 'eq', value: external_event_id });
search_query.and.push({
field: 'external_event_id',
op: 'eq',
value: external_event_id
});
}
if (type_code) {
search_query.and.push({ field: 'badge_type_code', op: 'eq', value: type_code });
search_query.and.push({
field: 'badge_type_code',
op: 'eq',
value: type_code
});
}
if (printed_status === 'printed') {
@@ -448,11 +505,15 @@ export async function search__event_badge({
search_query.and.push({ field: 'print_count', op: 'eq', value: 0 });
}
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: true });
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: false });
if (enabled === 'enabled')
search_query.and.push({ field: 'enable', op: 'eq', value: true });
else if (enabled === 'not_enabled')
search_query.and.push({ field: 'enable', op: 'eq', value: false });
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: true });
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: false });
if (hidden === 'hidden')
search_query.and.push({ field: 'hide', op: 'eq', value: true });
else if (hidden === 'not_hidden')
search_query.and.push({ field: 'hide', op: 'eq', value: false });
ae_promises.search__event_badge_obj_li = await api
.search_ae_obj({
@@ -473,17 +534,21 @@ export async function search__event_badge({
let result_li: ae_EventBadge[] = [];
if (Array.isArray(badge_obj_li_get_result)) {
result_li = badge_obj_li_get_result;
} else if (badge_obj_li_get_result?.data && Array.isArray(badge_obj_li_get_result.data)) {
} else if (
badge_obj_li_get_result?.data &&
Array.isArray(badge_obj_li_get_result.data)
) {
result_li = badge_obj_li_get_result.data;
}
if (result_li.length > 0) {
if (try_cache) {
const processed_obj_li = await process_ae_obj__event_badge_props({
obj_li: result_li,
event_id,
log_lvl
});
const processed_obj_li =
await process_ae_obj__event_badge_props({
obj_li: result_li,
event_id,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'badge',
@@ -631,14 +696,21 @@ async function _process_generic_props<T extends Record<string, any>>({
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on ?? new Date(0).toISOString();
const updated =
processed_obj.updated_on ??
processed_obj.created_on ??
new Date(0).toISOString();
const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
(processed_obj as any).tmp_sort_1 =
`${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 =
`${group}_${priority}_${sort}_${name}_${updated}`;
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
processed_obj = await Promise.resolve(
specific_processor(processed_obj)
);
}
processed_obj_li.push(processed_obj as T);
@@ -663,7 +735,9 @@ export async function process_ae_obj__event_badge_props({
log_lvl,
specific_processor: (obj) => {
if (log_lvl) {
console.log(`*** process_ae_obj__event_badge_props() *** event_id=${event_id}`);
console.log(
`*** process_ae_obj__event_badge_props() *** event_id=${event_id}`
);
}
if (event_id) {
if (!obj.event_id) obj.event_id = event_id;
@@ -672,4 +746,4 @@ export async function process_ae_obj__event_badge_props({
return obj;
}
});
}
}