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.
This commit is contained in:
@@ -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<T extends Record<string, any>>({
|
||||
// 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') ?? ''
|
||||
|
||||
Reference in New Issue
Block a user