From 266363b85febd573dc3dba6ebdcb30d4f849160b Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 20 Nov 2025 17:44:21 -0500 Subject: [PATCH] feat(event_badge): Improve event_id handling in badge data processing Refactor how is ensured in badge objects when fetched from the API and cached locally. Previously, directly injected into results, creating an inconsistency with other data fetching functions. This change centralizes the injection logic within . - Updated to accept an optional parameter. - Added logic within the processor to set and on badge objects if they are missing, using the provided context. - Modified call sites (, , ) to pass the to the function. This ensures consistent and robust handling of the across badge-related data operations, aligning with the project's data processing patterns. --- src/lib/ae_events/ae_events__event_badge.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/ae_events/ae_events__event_badge.ts b/src/lib/ae_events/ae_events__event_badge.ts index 9b4507c8..40c26ecc 100644 --- a/src/lib/ae_events/ae_events__event_badge.ts +++ b/src/lib/ae_events/ae_events__event_badge.ts @@ -140,6 +140,7 @@ export async function load_ae_obj_li__event_badge({ if (try_cache) { const processed_obj_li = await process_ae_obj__event_badge_props({ obj_li: badge_obj_li_get_result, + event_id, log_lvl }); await db_save_ae_obj_li__ae_obj({ @@ -220,6 +221,7 @@ export async function create_ae_obj__event_badge({ if (try_cache) { const processed_obj_li = await process_ae_obj__event_badge_props({ obj_li: [event_badge_obj_create_result], + event_id, log_lvl }); db_save_ae_obj_li__ae_obj({ @@ -510,6 +512,7 @@ export async function search__event_badge({ if (try_cache) { const processed_obj_li = await process_ae_obj__event_badge_props({ obj_li: badge_obj_li_get_result, + event_id, log_lvl }); await db_save_ae_obj_li__ae_obj({ @@ -686,9 +689,11 @@ async function _process_generic_props>({ // Updated 2025-10-06 export async function process_ae_obj__event_badge_props({ obj_li, + event_id, log_lvl = 0 }: { obj_li: any[]; + event_id?: string; log_lvl?: number; }) { return _process_generic_props({ @@ -696,6 +701,12 @@ export async function process_ae_obj__event_badge_props({ obj_type: 'event_badge', log_lvl, specific_processor: (obj) => { + // If the event_id isn't returned from the API, add it here. + if (event_id) { + if (!obj.event_id) obj.event_id = event_id; + if (!obj.event_id_random) obj.event_id_random = event_id; + } + // Event badge-specific computed sort fields, overriding generic ones if needed obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${ obj.sort?.toString().padStart(3, '0') ?? ''