Quick snapshot again as Gemini is working.

This commit is contained in:
Scott Idem
2025-11-13 12:44:28 -05:00
parent dfaa27384b
commit db8c0e0d05
14 changed files with 1294 additions and 1297 deletions

View File

@@ -1144,124 +1144,94 @@ export const properties_to_save = [
];
// Updated 2025-05-09
export async function process_ae_obj__event_props({
obj_li,
log_lvl = 0,
}: {
obj_li: any[];
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** process_ae_obj__event_props() ***`, obj_li);
}
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl) {
console.log('No objects to process.');
}
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li = [];
const processed_obj_li: T[] = [];
for (const obj of obj_li) {
if (log_lvl) {
console.log(`Processing ae_obj event:`, obj);
}
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// Create the processed object
let processed_obj = {
id: obj.event_id_random,
event_id: obj.event_id_random,
event_id_random: obj.event_id_random,
// --- Common Transformations ---
code: obj.event_code,
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
processed_obj.id = processed_obj[randomIdKey];
}
account_id: obj.account_id_random,
account_id_random: obj.account_id_random,
// 2. Create common computed properties for client-side sorting.
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;
const name = processed_obj.name ?? '';
conference: obj.conference,
type: obj.type,
name: obj.name,
summary: obj.summary,
description: obj.description,
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
start_datetime: obj.start_datetime,
end_datetime: obj.end_datetime,
timezone: obj.timezone,
location_address_json: obj.location_address_json,
location_text: obj.location_text,
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
attend_json: obj.attend_json,
attend_text: obj.attend_text,
processed_obj_li.push(processed_obj as T);
}
status: obj.status, // draft, active, inactive, archived, unknown; currently only used with IDAA
// review: obj.review,
// approve: obj.approve,
// ready: obj.ready,
// ready_on: obj.ready_on,
// archive: obj.archive,
// archive_on: obj.archive_on,
mod_abstracts_json: obj.mod_abstracts_json,
mod_badges_json: obj.mod_badges_json,
mod_exhibits_json: obj.mod_exhibits_json,
mod_meetings_json: obj.mod_meetings_json,
mod_pres_mgmt_json: obj.mod_pres_mgmt_json,
cfg_json: obj.cfg_json,
enable: obj.enable,
hide: obj.hide,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
// IDAA Recovery Meetings:
// Currently only really used for IDAA
contact_li_json: obj.contact_li_json,
external_person_id: obj.external_person_id,
physical: obj.physical,
virtual: obj.virtual,
recurring: obj.recurring,
recurring_pattern: obj.recurring_pattern,
recurring_start_time: obj.recurring_start_time,
recurring_end_time: obj.recurring_end_time,
recurring_text: obj.recurring_text,
weekday_sunday: obj.weekday_sunday,
weekday_monday: obj.weekday_monday,
weekday_tuesday: obj.weekday_tuesday,
weekday_wednesday: obj.weekday_wednesday,
weekday_thursday: obj.weekday_thursday,
weekday_friday: obj.weekday_friday,
weekday_saturday: obj.weekday_saturday,
attend_url: obj.attend_url,
attend_url_text: obj.attend_url_text,
attend_url_code: obj.attend_url_code,
attend_url_passcode: obj.attend_url_passcode,
attend_phone: obj.attend_phone,
attend_phone_passcode: obj.attend_phone_passcode,
// From SQL view
file_count: obj.file_count,
file_count_all: obj.file_count_all,
internal_use_count: obj.internal_use_count,
event_file_id_li_json: obj.event_file_id_li_json,
};
processed_obj_li.push(processed_obj);
}
return processed_obj_li;
return processed_obj_li;
}
// Updated 2025-11-13
export async function process_ae_obj__event_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'event',
log_lvl,
specific_processor: (obj) => {
// Handle event-specific property aliases
if (obj.event_code) {
obj.code = obj.event_code;
}
return obj;
}
});
}