The Event and Event Session should now be using the new IDB save method and related updates. Need to TEST TEST TEST more now.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_device } from './ae_events__event_device';
|
||||
@@ -49,14 +50,36 @@ export async function load_ae_obj_id__event(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_get_result) {
|
||||
.then(async function (event_obj_get_result) {
|
||||
if (event_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event({
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_get_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event({
|
||||
// obj_type: 'event',
|
||||
// obj_li: [event_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_obj_get_result;
|
||||
} else {
|
||||
@@ -195,10 +218,32 @@ export async function load_ae_obj_li__event(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_li_get_result) {
|
||||
.then(async function (event_obj_li_get_result) {
|
||||
if (event_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: event_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
}
|
||||
return event_obj_li_get_result;
|
||||
} else {
|
||||
@@ -369,15 +414,37 @@ export async function create_ae_obj__event(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
.then(async function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event(
|
||||
// {
|
||||
// obj_type: 'event',
|
||||
// obj_li: [event_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
@@ -480,12 +547,34 @@ export async function update_ae_obj__event(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_update_result) {
|
||||
.then(async function (event_obj_update_result) {
|
||||
if (event_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({
|
||||
obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'events',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
// db_save_ae_obj_li__event({
|
||||
// obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_obj_update_result;
|
||||
} else {
|
||||
@@ -747,4 +836,219 @@ export function sync_config__event_pres_mgmt(
|
||||
console.log(`pres_mgmt_cfg_local:`, pres_mgmt_cfg_local);
|
||||
}
|
||||
return pres_mgmt_cfg_local;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
|
||||
'code',
|
||||
|
||||
'account_id',
|
||||
'account_id_random',
|
||||
|
||||
'conference',
|
||||
'type',
|
||||
'name',
|
||||
'summary',
|
||||
'description',
|
||||
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
'timezone',
|
||||
|
||||
'location_address_json',
|
||||
'location_text',
|
||||
|
||||
'attend_json',
|
||||
'attend_text',
|
||||
|
||||
'status', // draft, active, inactive, archived, unknown; currently only used with IDAA
|
||||
// review
|
||||
// approve
|
||||
// ready
|
||||
// ready_on
|
||||
// archive
|
||||
// archive_on
|
||||
|
||||
'mod_abstracts_json',
|
||||
'mod_badges_json',
|
||||
'mod_exhibits_json',
|
||||
'mod_pres_mgmt_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// IDAA Recovery Meetings:
|
||||
// Currently only really used for IDAA
|
||||
'contact_li_json',
|
||||
'external_person_id',
|
||||
|
||||
'physical',
|
||||
'virtual',
|
||||
|
||||
'recurring',
|
||||
'recurring_pattern',
|
||||
'recurring_start_time',
|
||||
'recurring_end_time',
|
||||
'recurring_text',
|
||||
|
||||
'weekday_sunday',
|
||||
'weekday_monday',
|
||||
'weekday_tuesday',
|
||||
'weekday_wednesday',
|
||||
'weekday_thursday',
|
||||
'weekday_friday',
|
||||
'weekday_saturday',
|
||||
|
||||
'attend_url',
|
||||
'attend_url_text',
|
||||
'attend_url_passcode',
|
||||
'attend_phone',
|
||||
'attend_phone_passcode',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
// 'tmp_sort_1',
|
||||
// 'tmp_sort_2',
|
||||
// 'tmp_sort_3',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
// 'event_session_count',
|
||||
// 'event_presenter_count',
|
||||
// 'event_file_count',
|
||||
|
||||
// A key value list of the others
|
||||
// 'event_other_kv',
|
||||
// 'event_other_li',
|
||||
];
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event:`, 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,
|
||||
|
||||
code: obj.event_code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
conference: obj.conference,
|
||||
type: obj.type,
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
description: obj.description,
|
||||
|
||||
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,
|
||||
|
||||
attend_json: obj.attend_json,
|
||||
attend_text: obj.attend_text,
|
||||
|
||||
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_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,
|
||||
|
||||
// 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_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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user