refactor: Standardize data processing and update to Svelte 5 runes
This commit introduces a major refactoring of the data processing logic across multiple modules (events, archives, posts, sponsorships) to use a standardized pattern with . This improves consistency and maintainability. Key changes: - Replaced module-specific data processing with a generic helper. - Removed deprecated functions. - Updated Svelte components to leverage the new Svelte 5 runes, simplifying state management. - Fixed linting errors and updated test configurations. - Added .
This commit is contained in:
@@ -576,13 +576,31 @@ export async function qry__archive(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_obj_li_get_result) {
|
||||
.then(async function (archive_obj_li_get_result) {
|
||||
if (archive_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive',
|
||||
obj_li: archive_obj_li_get_result
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: archive_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'archive',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return archive_obj_li_get_result;
|
||||
} else {
|
||||
@@ -734,82 +752,7 @@ export async function qry__archive(
|
||||
// }
|
||||
|
||||
|
||||
// This function will loop through the archive_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__archive(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__archive() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_archives.archive.put({
|
||||
id: obj.archive_id_random,
|
||||
archive_id: obj.archive_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
sort_by: obj.sort_by,
|
||||
sort_by_desc: obj.sort_by_desc,
|
||||
|
||||
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,
|
||||
|
||||
// From SQL view
|
||||
// archive_content_count: obj.archive_content_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// archive_content_kv: obj.archive_content_kv,
|
||||
// archive_content_li: obj.archive_content_li,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.archive_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.archive_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_archives.archive.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.archive_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
|
||||
@@ -406,96 +406,7 @@ export async function update_ae_obj__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the archive_content_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export async function db_save_ae_obj_li__archive_content(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__archive_content() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_archives.content.put({
|
||||
id: obj.archive_content_id_random,
|
||||
archive_content_id: obj.archive_content_id_random,
|
||||
|
||||
archive_id: obj.archive_id_random,
|
||||
|
||||
archive_content_type: obj.archive_content_type,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
content_html: obj.content_html,
|
||||
content_json: obj.content_json,
|
||||
|
||||
url: obj.url,
|
||||
url_text: obj.url_text,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
|
||||
file_path: obj.file_path,
|
||||
|
||||
filename: obj.filename,
|
||||
file_extension: obj.file_extension,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
enable_for_public: obj.enable_for_public,
|
||||
|
||||
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.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
|
||||
|
||||
// From SQL view
|
||||
archive_code: obj.archive_code,
|
||||
archive_name: obj.archive_name,
|
||||
|
||||
hash_sha256: obj.hosted_file_hash_sha256 ?? ''
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.archive_content_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.archive_content_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_archives.content.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.archive_content_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
create_ae_obj__archive,
|
||||
delete_ae_obj_id__archive,
|
||||
update_ae_obj__archive,
|
||||
// qry__archive,
|
||||
db_save_ae_obj_li__archive,
|
||||
|
||||
} from "$lib/ae_archives/ae_archives__archive";
|
||||
|
||||
|
||||
@@ -17,8 +16,7 @@ import {
|
||||
create_ae_obj__archive_content,
|
||||
delete_ae_obj_id__archive_content,
|
||||
update_ae_obj__archive_content,
|
||||
// qry__archive_content,
|
||||
db_save_ae_obj_li__archive_content,
|
||||
|
||||
} from "$lib/ae_archives/ae_archives__archive_content";
|
||||
|
||||
|
||||
@@ -28,13 +26,13 @@ let export_obj = {
|
||||
create_ae_obj__archive: create_ae_obj__archive,
|
||||
delete_ae_obj_id__archive: delete_ae_obj_id__archive,
|
||||
update_ae_obj__archive: update_ae_obj__archive,
|
||||
db_save_ae_obj_li__archive: db_save_ae_obj_li__archive,
|
||||
|
||||
|
||||
load_ae_obj_id__archive_content: load_ae_obj_id__archive_content,
|
||||
load_ae_obj_li__archive_content: load_ae_obj_li__archive_content,
|
||||
create_ae_obj__archive_content: create_ae_obj__archive_content,
|
||||
delete_ae_obj_id__archive_content: delete_ae_obj_id__archive_content,
|
||||
update_ae_obj__archive_content: update_ae_obj__archive_content,
|
||||
db_save_ae_obj_li__archive_content: db_save_ae_obj_li__archive_content,
|
||||
|
||||
};
|
||||
export let archives_func = export_obj;
|
||||
@@ -1,6 +1,6 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
@@ -510,31 +510,7 @@ export async function search__event_badge({
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-10-06
|
||||
export async function db_save_ae_obj_li__event_badge({
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any[],
|
||||
log_lvl?: number
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_badge() *** obj_type=${obj_type}`, obj_li);
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to save.');
|
||||
return [];
|
||||
}
|
||||
return await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge',
|
||||
obj_li,
|
||||
properties_to_save,
|
||||
log_lvl,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Updated 2025-10-06
|
||||
|
||||
@@ -178,31 +178,7 @@ export async function process_ae_obj__event_badge_template_props({
|
||||
}
|
||||
|
||||
|
||||
// --- DB SAVE FUNCTION ---
|
||||
export async function db_save_ae_obj_li__event_badge_template({
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any[],
|
||||
log_lvl?: number
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_badge_template() *** obj_type=${obj_type}`, obj_li);
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to save.');
|
||||
return [];
|
||||
}
|
||||
return await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li,
|
||||
properties_to_save,
|
||||
log_lvl,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- CRUD FUNCTIONS ---
|
||||
|
||||
@@ -557,10 +557,31 @@ export async function search__event_device(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_device_obj_li_get_result) {
|
||||
.then(async function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_device({obj_type: 'event_device', obj_li: event_device_obj_li_get_result});
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: event_device_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'device',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return event_device_obj_li_get_result;
|
||||
} else {
|
||||
@@ -580,106 +601,7 @@ export async function search__event_device(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_device_obj_li and save each one to the DB.
|
||||
// Updated 2024-10-16
|
||||
export function db_save_ae_obj_li__event_device(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_device() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.device.put({
|
||||
id: obj.event_device_id_random,
|
||||
event_device_id: obj.event_device_id_random,
|
||||
// event_device_id_random: obj.event_device_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
// event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
// event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
code: obj.code,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
local_file_cache_path: obj.local_file_cache_path,
|
||||
host_file_temp_path: obj.host_file_temp_path,
|
||||
recording_path: obj.recording_path,
|
||||
|
||||
record_audio: obj.record_audio,
|
||||
record_video: obj.record_video,
|
||||
|
||||
trigger_open_file_id: obj.trigger_open_file_id,
|
||||
trigger_open_session_id: obj.trigger_open_session_id,
|
||||
trigger_recording_start: obj.trigger_recording_start,
|
||||
trigger_recording_stop: obj.trigger_recording_stop,
|
||||
trigger_reset: obj.trigger_reset,
|
||||
trigger_show_admin: obj.trigger_show_admin,
|
||||
trigger_show_hidden: obj.trigger_show_hidden,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
alert_on: obj.alert_on,
|
||||
status: obj.status,
|
||||
status_msg: obj.status_msg,
|
||||
status_on: obj.status_on,
|
||||
record_status: obj.record_status,
|
||||
record_status_msg: obj.record_status_msg,
|
||||
record_status_on: obj.record_status_on,
|
||||
// These are timestamps that are in UTC but missing the 'Z' at the end
|
||||
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
|
||||
|
||||
info_hostname: obj.info_hostname,
|
||||
info_ip_list: obj.info_ip_list,
|
||||
|
||||
meta_json: obj.meta_json,
|
||||
other_json: obj.other_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,
|
||||
|
||||
// From SQL view
|
||||
event_name: obj.event_name,
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_device_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.device.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
|
||||
@@ -675,193 +675,9 @@ export async function search__event_file(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_file_obj_li and save each one to the DB.
|
||||
// Updated 2024-10-04
|
||||
export function db_save_ae_obj_li__event_file(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_file() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.file.put({
|
||||
id: obj.event_file_id_random,
|
||||
id_random: obj.event_file_id_random,
|
||||
event_file_id: obj.event_file_id_random,
|
||||
event_file_id_random: obj.event_file_id_random,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
filename: obj.filename,
|
||||
extension: obj.extension,
|
||||
|
||||
open_in_os: obj.open_in_os,
|
||||
|
||||
lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case?
|
||||
lu_event_file_purpose_name: obj.lu_event_file_purpose_name,
|
||||
file_purpose: obj.file_purpose,
|
||||
|
||||
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,
|
||||
|
||||
filename_no_ext: obj.filename_no_ext,
|
||||
filename_w_ext: obj.filename_w_ext,
|
||||
hosted_file_content_type: obj.hosted_file_content_type,
|
||||
file_size: obj.file_size,
|
||||
hosted_file_size: obj.hosted_file_size,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_type_code: obj.event_session_type_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_session_end_datetime: obj.event_session_end_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_type_code: obj.event_presentation_type_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
event_presentation_end_datetime: obj.event_presentation_end_datetime,
|
||||
event_presenter_given_name: obj.event_presenter_given_name,
|
||||
event_presenter_family_name: obj.event_presenter_family_name,
|
||||
event_presenter_full_name: obj.event_presenter_full_name,
|
||||
event_presenter_email: obj.event_presenter_email,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_file_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_file_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.file.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_file_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
export function db_update_ae_obj_id__event_file(
|
||||
{
|
||||
obj_type,
|
||||
obj_id,
|
||||
data_kv,
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_id: string,
|
||||
data_kv: key_val
|
||||
}
|
||||
) {
|
||||
console.log(`*** db_update_ae_obj_id__event_file() ***`);
|
||||
|
||||
if (obj_id) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj_id);
|
||||
|
||||
try {
|
||||
// db_events.file.update(obj_id, data_kv);
|
||||
db_events.file.update(obj_id,
|
||||
{
|
||||
// for_type: data_kv.for_type,
|
||||
// for_id: data_kv.for_id_id_random,
|
||||
// for_id_random: data_kv.for_id_random,
|
||||
|
||||
// event_id_random: data_kv.event_id_random,
|
||||
// event_session_id_random: data_kv.event_session_id_random,
|
||||
// event_presentation_id_random: data_kv.event_presentation_id_random,
|
||||
// event_presenter_id_random: data_kv.event_presenter_id_random,
|
||||
// event_location_id_random: data_kv.event_location_id_random,
|
||||
|
||||
filename: data_kv.filename,
|
||||
extension: data_kv.extension,
|
||||
|
||||
open_in_os: data_kv.open_in_os,
|
||||
|
||||
// lu_file_purpose_id: data_kv.lu_file_purpose_id, // Not id_random in this case?
|
||||
// lu_event_file_purpose_name: data_kv.lu_event_file_purpose_name,
|
||||
file_purpose: data_kv.file_purpose,
|
||||
|
||||
// enable: data_kv.enable,
|
||||
// hide: data_kv.hide,
|
||||
// priority: data_kv.priority,
|
||||
// sort: data_kv.sort,
|
||||
// group: data_kv.group,
|
||||
// notes: data_kv.notes,
|
||||
// created_on: data_kv.created_on,
|
||||
// updated_on: data_kv.updated_on,
|
||||
|
||||
filename_no_ext: data_kv.filename_no_ext,
|
||||
filename_w_ext: data_kv.filename_w_ext,
|
||||
// hosted_file_content_type: data_kv.hosted_file_content_type,
|
||||
// file_size: data_kv.file_size,
|
||||
// hosted_file_size: data_kv.hosted_file_size,
|
||||
|
||||
// event_location_code: data_kv.event_location_code,
|
||||
// event_location_name: data_kv.event_location_name,
|
||||
// event_session_code: data_kv.event_session_code,
|
||||
// event_session_name: data_kv.event_session_name,
|
||||
// event_session_start_datetime: data_kv.event_session_start_datetime,
|
||||
// event_presentation_code: data_kv.event_presentation_code,
|
||||
// event_presentation_name: data_kv.event_presentation_name,
|
||||
// event_presentation_start_datetime: data_kv.event_presentation_start_datetime,
|
||||
// event_presenter_given_name: data_kv.event_presenter_given_name,
|
||||
// event_presenter_family_name: data_kv.event_presenter_family_name,
|
||||
// event_presenter_full_name: data_kv.event_presenter_full_name,
|
||||
// event_presenter_email: data_kv.event_presenter_email,
|
||||
}
|
||||
);
|
||||
|
||||
console.log(`Update obj with ID: ${obj_id}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to update ${obj_id}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.file.put(obj);
|
||||
// console.log(`Put obj with ID: ${data_kv.event_file_id_random}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
|
||||
@@ -659,10 +659,31 @@ export async function search__event_location(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_li_get_result) {
|
||||
.then(async function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result});
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: event_location_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return event_location_obj_li_get_result;
|
||||
} else {
|
||||
@@ -682,92 +703,7 @@ export async function search__event_location(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_location_obj_li and save each one to the DB.
|
||||
// Updated 2024-06-25
|
||||
export function db_save_ae_obj_li__event_location(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_location() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.location.put({
|
||||
id: obj.event_location_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_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,
|
||||
|
||||
// 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,
|
||||
|
||||
// poc_person_given_name: obj.poc_person_given_name,
|
||||
// poc_person_family_name: obj.poc_person_family_name,
|
||||
// poc_person_full_name: obj.poc_person_full_name,
|
||||
// poc_person_primary_email: obj.poc_person_primary_email,
|
||||
// poc_person_passcode: obj.poc_person_passcode,
|
||||
// poc_kv_json: obj.poc_kv_json,
|
||||
|
||||
event_name: obj.event_name,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_location_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_location_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.location.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_location_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
|
||||
@@ -563,93 +563,7 @@ export async function update_ae_obj__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_presentation_obj_li and save each one to the DB.
|
||||
// Updated 2024-06-10
|
||||
export function db_save_ae_obj_li__event_presentation(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_presentation() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.presentation.put({
|
||||
id: obj.event_presentation_id_random,
|
||||
// id_random: obj.event_presentation_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_abstract_id: obj.event_abstract_id_random,
|
||||
event_abstract_id_random: obj.event_abstract_id_random,
|
||||
|
||||
abstract_code: obj.abstract_code,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
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,
|
||||
|
||||
// From SQL view
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
|
||||
// A key value list of the presenters
|
||||
// event_presenter_kv: obj.event_presenter_kv,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_presentation_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_presentation_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.presentation.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_presentation_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
|
||||
@@ -607,15 +607,32 @@ export async function search__event_presenter(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_presenter_obj_li_get_result) {
|
||||
.then(async function (event_presenter_obj_li_get_result) {
|
||||
if (event_presenter_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_presenter({
|
||||
obj_type: 'event_presenter',
|
||||
obj_li: event_presenter_obj_li_get_result
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presenter_props({
|
||||
obj_li: event_presenter_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presenter',
|
||||
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_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result});
|
||||
return event_presenter_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -634,124 +651,7 @@ export async function search__event_presenter(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export function db_save_ae_obj_li__event_presenter(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_presenter() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.presenter.put({
|
||||
id: obj.event_presenter_id_random,
|
||||
// id_random: obj.event_presenter_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
// for_type: obj.for_type,
|
||||
// for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_person_id: obj.event_person_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
email: obj.email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
data_json: obj.data_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,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
|
||||
person_external_id: obj.person_external_id,
|
||||
person_external_sys_id: obj.person_external_sys_id,
|
||||
person_given_name: obj.person_given_name,
|
||||
person_family_name: obj.person_family_name,
|
||||
person_full_name: obj.person_full_name,
|
||||
person_professional_title: obj.person_professional_title,
|
||||
person_affiliations: obj.person_affiliations,
|
||||
person_primary_email: obj.person_primary_email,
|
||||
person_passcode: obj.person_passcode,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_presenter_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_presenter_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.presenter.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_presenter_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-08-07
|
||||
|
||||
@@ -3,11 +3,203 @@ import { api } from '$lib/api/api';
|
||||
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save_exhibit_tracking = [
|
||||
'id',
|
||||
'event_exhibit_tracking_id',
|
||||
'event_exhibit_id',
|
||||
'event_badge_id',
|
||||
'event_person_id',
|
||||
'external_person_id',
|
||||
'exhibitor_notes',
|
||||
'responses_json',
|
||||
'data_json',
|
||||
'event_exhibit_name',
|
||||
'event_badge_title_names',
|
||||
'event_badge_given_name',
|
||||
'event_badge_family_name',
|
||||
'event_badge_designations',
|
||||
'event_badge_full_name',
|
||||
'event_badge_full_name_override',
|
||||
'event_badge_professional_title',
|
||||
'event_badge_professional_title_override',
|
||||
'event_badge_affiliations',
|
||||
'event_badge_affiliations_override',
|
||||
'event_badge_email',
|
||||
'event_badge_email_override',
|
||||
'event_badge_location',
|
||||
'event_badge_location_override',
|
||||
'event_badge_country',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
];
|
||||
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__exhibit_tracking_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event exhibit tracking-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') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_exhibit_id',
|
||||
'event_id',
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'staff_passcode',
|
||||
'data_json',
|
||||
'leads_api_access',
|
||||
'leads_custom_questions_json',
|
||||
'leads_device_sm_qty',
|
||||
'leads_device_lg_qty',
|
||||
'license_max',
|
||||
'license_li_json',
|
||||
'cfg_json',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 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 > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 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 as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 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 ?? '';
|
||||
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__exhibit_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_exhibit',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event exhibit-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') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-03
|
||||
export async function handle_load_ae_obj_id__exhibit(
|
||||
export async function load_ae_obj_id__exhibit(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
@@ -20,7 +212,7 @@ export async function handle_load_ae_obj_id__exhibit(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -34,10 +226,32 @@ export async function handle_load_ae_obj_id__exhibit(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (exhibit_obj_get_result) {
|
||||
.then(async function (exhibit_obj_get_result) {
|
||||
if (exhibit_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: [exhibit_obj_get_result]});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: [exhibit_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: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
@@ -53,7 +267,7 @@ export async function handle_load_ae_obj_id__exhibit(
|
||||
|
||||
|
||||
// Updated 2024-03-06
|
||||
export async function handle_load_ae_obj_li__exhibit(
|
||||
export async function load_ae_obj_li__exhibit(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
@@ -68,7 +282,7 @@ export async function handle_load_ae_obj_li__exhibit(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
@@ -113,11 +327,33 @@ export async function handle_load_ae_obj_li__exhibit(
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(function (exhibit_obj_li_get_result) {
|
||||
.then(async function (exhibit_obj_li_get_result) {
|
||||
// console.log('Badge list:', exhibit_obj_li_get_result);
|
||||
if (exhibit_obj_li_get_result) {
|
||||
// $slct.exhibit_obj_li = exhibit_obj_li_get_result;
|
||||
handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: exhibit_obj_li_get_result});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: exhibit_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_obj_li_get_result;
|
||||
} else {
|
||||
// $slct.exhibit_obj_li = [];
|
||||
@@ -141,7 +377,7 @@ export async function handle_load_ae_obj_li__exhibit(
|
||||
}
|
||||
|
||||
|
||||
export async function handle_load_ae_obj_id__exhibit_tracking(
|
||||
export async function load_ae_obj_id__exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
@@ -154,7 +390,7 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`);
|
||||
console.log(`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -168,10 +404,32 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (exhibit_tracking_obj_get_result) {
|
||||
.then(async function (exhibit_tracking_obj_get_result) {
|
||||
if (exhibit_tracking_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_get_result]});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
@@ -187,7 +445,7 @@ export async function handle_load_ae_obj_id__exhibit_tracking(
|
||||
|
||||
|
||||
// Updated 2024-03-19
|
||||
export async function handle_load_ae_obj_li__exhibit_tracking(
|
||||
export async function load_ae_obj_li__exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
@@ -202,7 +460,7 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
@@ -228,11 +486,33 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(function (exhibit_tracking_obj_li_get_result) {
|
||||
.then(async function (exhibit_tracking_obj_li_get_result) {
|
||||
// console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result);
|
||||
if (exhibit_tracking_obj_li_get_result) {
|
||||
// $slct.exhibit_tracking_obj_li = exhibit_tracking_obj_li_get_result;
|
||||
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: exhibit_tracking_obj_li_get_result});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: exhibit_tracking_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_li_get_result;
|
||||
} else {
|
||||
// $slct.exhibit_tracking_obj_li = [];
|
||||
@@ -255,7 +535,7 @@ export async function handle_load_ae_obj_li__exhibit_tracking(
|
||||
|
||||
|
||||
// Updated 2024-03-22
|
||||
export async function handle_create_ae_obj__exhibit_tracking(
|
||||
export async function create_ae_obj__exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
@@ -291,11 +571,33 @@ export async function handle_create_ae_obj__exhibit_tracking(
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(function (exhibit_tracking_obj_create_result) {
|
||||
.then(async function (exhibit_tracking_obj_create_result) {
|
||||
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
|
||||
if (exhibit_tracking_obj_create_result) {
|
||||
// $slct.exhibit_tracking_obj = exhibit_tracking_obj_create_result;
|
||||
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_create_result]});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_create_result;
|
||||
} else {
|
||||
// $slct.exhibit_tracking_obj = [];
|
||||
@@ -318,7 +620,7 @@ export async function handle_create_ae_obj__exhibit_tracking(
|
||||
|
||||
|
||||
// Updated 2024-03-28
|
||||
export async function handle_update_ae_obj__exhibit_tracking(
|
||||
export async function update_ae_obj__exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
@@ -345,9 +647,32 @@ export async function handle_update_ae_obj__exhibit_tracking(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (exhibit_tracking_obj_update_result) {
|
||||
.then(async function (exhibit_tracking_obj_update_result) {
|
||||
if (exhibit_tracking_obj_update_result) {
|
||||
handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_update_result]});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_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: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -366,7 +691,7 @@ export async function handle_update_ae_obj__exhibit_tracking(
|
||||
}
|
||||
|
||||
|
||||
export async function handle_download_export__event_exhibit_tracking(
|
||||
export async function download_export__event_exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
@@ -412,153 +737,7 @@ export async function handle_download_export__event_exhibit_tracking(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_exhibit_obj_li and save each one to the DB.
|
||||
export function handle_db_save_ae_obj_li__exhibitor(
|
||||
{
|
||||
obj_type,
|
||||
obj_li=[],
|
||||
log_lvl=0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any[],
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__exhibitor() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.exhibit.put({
|
||||
id_random: obj.event_exhibit_id_random,
|
||||
event_exhibit_id_random: obj.event_exhibit_id_random,
|
||||
|
||||
event_id_random: obj.event_id_random,
|
||||
code: obj.code,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
staff_passcode: obj.staff_passcode,
|
||||
data_json: obj.data_json,
|
||||
|
||||
leads_api_access: obj.leads_api_access,
|
||||
leads_custom_questions_json: obj.leads_custom_questions_json,
|
||||
leads_device_sm_qty: obj.leads_device_sm_qty,
|
||||
leads_device_lg_qty: obj.leads_device_lg_qty,
|
||||
license_max: obj.license_max,
|
||||
license_li_json: obj.license_li_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,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_exhibit_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_exhibit_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.exhibit.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_exhibit_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_exhibit_tracking_obj_li and save each one to the DB.
|
||||
export function handle_db_save_ae_obj_li__exhibitor_tracking(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl=0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__exhibitor_tracking() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.exhibit_tracking.put({
|
||||
id_random: obj.event_exhibit_tracking_id_random,
|
||||
event_exhibit_tracking_id_random: obj.event_exhibit_tracking_id_random,
|
||||
|
||||
event_exhibit_id_random: obj.event_exhibit_id_random,
|
||||
event_badge_id_random: obj.event_badge_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
exhibitor_notes: obj.exhibitor_notes,
|
||||
|
||||
responses_json: obj.responses_json,
|
||||
data_json: obj.data_json,
|
||||
|
||||
event_exhibit_name: obj.event_exhibit_name,
|
||||
|
||||
event_badge_title_names: obj.event_badge_title_names,
|
||||
event_badge_given_name: obj.event_badge_given_name,
|
||||
event_badge_family_name: obj.event_badge_family_name,
|
||||
event_badge_designations: obj.event_badge_designations,
|
||||
event_badge_full_name: obj.event_badge_full_name,
|
||||
event_badge_full_name_override: obj.event_badge_full_name_override,
|
||||
|
||||
event_badge_professional_title: obj.event_badge_professional_title,
|
||||
event_badge_professional_title_override: obj.event_badge_professional_title_override,
|
||||
|
||||
event_badge_affiliations: obj.event_badge_affiliations,
|
||||
event_badge_affiliations_override: obj.event_badge_affiliations_override,
|
||||
|
||||
event_badge_email: obj.event_badge_email,
|
||||
event_badge_email_override: obj.event_badge_email_override,
|
||||
|
||||
event_badge_location: obj.event_badge_location,
|
||||
event_badge_location_override: obj.event_badge_location_override,
|
||||
|
||||
event_badge_country: obj.event_badge_country,
|
||||
|
||||
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,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_exhibit_tracking_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.exhibit_tracking.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
@@ -7,14 +7,14 @@ import * as event_device from "$lib/ae_events/ae_events__event_device";
|
||||
import * as event_file from "$lib/ae_events/ae_events__event_file";
|
||||
|
||||
import {
|
||||
handle_load_ae_obj_id__exhibit,
|
||||
handle_load_ae_obj_li__exhibit,
|
||||
handle_load_ae_obj_id__exhibit_tracking,
|
||||
handle_load_ae_obj_li__exhibit_tracking,
|
||||
handle_create_ae_obj__exhibit_tracking,
|
||||
handle_update_ae_obj__exhibit_tracking,
|
||||
handle_download_export__event_exhibit_tracking,
|
||||
handle_db_save_ae_obj_li__exhibitor,
|
||||
load_ae_obj_id__exhibit,
|
||||
load_ae_obj_li__exhibit,
|
||||
load_ae_obj_id__exhibit_tracking,
|
||||
load_ae_obj_li__exhibit_tracking,
|
||||
create_ae_obj__exhibit_tracking,
|
||||
update_ae_obj__exhibit_tracking,
|
||||
download_export__event_exhibit_tracking,
|
||||
// db_save_ae_obj_li__exhibitor,
|
||||
} from "$lib/ae_events/ae_events__exhibit";
|
||||
|
||||
import * as event_location from "$lib/ae_events/ae_events__event_location";
|
||||
@@ -71,14 +71,14 @@ let export_obj = {
|
||||
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
|
||||
|
||||
// Event Exhibits
|
||||
handle_load_ae_obj_id__exhibit: handle_load_ae_obj_id__exhibit,
|
||||
handle_load_ae_obj_li__exhibit: handle_load_ae_obj_li__exhibit,
|
||||
handle_load_ae_obj_id__exhibit_tracking: handle_load_ae_obj_id__exhibit_tracking,
|
||||
handle_load_ae_obj_li__exhibit_tracking: handle_load_ae_obj_li__exhibit_tracking,
|
||||
handle_create_ae_obj__exhibit_tracking: handle_create_ae_obj__exhibit_tracking,
|
||||
handle_update_ae_obj__exhibit_tracking: handle_update_ae_obj__exhibit_tracking,
|
||||
handle_download_export__event_exhibit_tracking: handle_download_export__event_exhibit_tracking,
|
||||
// handle_db_save_ae_obj_li__exhibitor: handle_db_save_ae_obj_li__exhibitor,
|
||||
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
||||
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
|
||||
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
|
||||
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
|
||||
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
|
||||
handle_update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
|
||||
handle_download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
|
||||
// handle_db_save_ae_obj_li__exhibitor: db_save_ae_obj_li__exhibitor,
|
||||
|
||||
// Event Files
|
||||
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
@@ -627,13 +627,32 @@ export async function qry__post(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_obj_li_get_result) {
|
||||
.then(async function (post_obj_li_get_result) {
|
||||
if (post_obj_li_get_result) {
|
||||
db_save_ae_obj_li__post({
|
||||
obj_type: 'post',
|
||||
obj_li: post_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_props({
|
||||
obj_li: post_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'post',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return post_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -784,92 +803,7 @@ export async function qry__post(
|
||||
// }
|
||||
|
||||
|
||||
// This function will loop through the post_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__post(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__post() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_posts.post.put({
|
||||
id: obj.post_id_random,
|
||||
post_id: obj.post_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_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,
|
||||
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
post_comment_count: obj.post_comment_count,
|
||||
|
||||
// A key value list of the comments
|
||||
// post_comment_kv: obj.post_comment_kv,
|
||||
// post_comment_li: obj.post_comment_li,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.post_id_random} or ${id_random}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.post_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
|
||||
@@ -412,78 +412,7 @@ export async function update_ae_obj__post_comment(
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the post_comment_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__post_comment(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__post_comment() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_posts.comment.put({
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
name: obj.name,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
linked_li_json: obj.linked_li_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,
|
||||
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.post_comment_id_random} or ${id_random}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.post_comment_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
create_ae_obj__post,
|
||||
delete_ae_obj_id__post,
|
||||
update_ae_obj__post,
|
||||
// qry__post,
|
||||
db_save_ae_obj_li__post,
|
||||
|
||||
} from "$lib/ae_posts/ae_posts__post";
|
||||
|
||||
|
||||
@@ -17,8 +16,7 @@ import {
|
||||
create_ae_obj__post_comment,
|
||||
delete_ae_obj_id__post_comment,
|
||||
update_ae_obj__post_comment,
|
||||
// qry__post_comment,
|
||||
db_save_ae_obj_li__post_comment,
|
||||
|
||||
} from "$lib/ae_posts/ae_posts__post_comment";
|
||||
|
||||
|
||||
@@ -28,13 +26,13 @@ let export_obj = {
|
||||
create_ae_obj__post: create_ae_obj__post,
|
||||
delete_ae_obj_id__post: delete_ae_obj_id__post,
|
||||
update_ae_obj__post: update_ae_obj__post,
|
||||
db_save_ae_obj_li__post: db_save_ae_obj_li__post,
|
||||
|
||||
|
||||
load_ae_obj_id__post_comment: load_ae_obj_id__post_comment,
|
||||
load_ae_obj_li__post_comment: load_ae_obj_li__post_comment,
|
||||
create_ae_obj__post_comment: create_ae_obj__post_comment,
|
||||
delete_ae_obj_id__post_comment: delete_ae_obj_id__post_comment,
|
||||
update_ae_obj__post_comment: update_ae_obj__post_comment,
|
||||
db_save_ae_obj_li__post_comment: db_save_ae_obj_li__post_comment,
|
||||
|
||||
};
|
||||
export let posts_func = export_obj;
|
||||
@@ -1,6 +1,6 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
@@ -6,7 +6,193 @@ import { db_sponsorships } from "$lib/ae_sponsorships/db_sponsorships";
|
||||
// import { liveQuery } from "dexie";
|
||||
// import { db_core } from "$lib/db_core";
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save_sponsorship_cfg = [
|
||||
'id',
|
||||
'sponsorship_cfg_id',
|
||||
'account_id',
|
||||
'for_type',
|
||||
'for_id',
|
||||
'level_li_json',
|
||||
'option_li_json',
|
||||
'schedule_li_json',
|
||||
'cfg_json',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
];
|
||||
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__sponsorship_cfg_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'sponsorship_cfg',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Sponsorship Cfg-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') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save_sponsorship = [
|
||||
'id',
|
||||
'sponsorship_id',
|
||||
'account_id',
|
||||
'organization_id',
|
||||
'person_id',
|
||||
'poc_person_id',
|
||||
'poc_json',
|
||||
'name',
|
||||
'name_override',
|
||||
'description',
|
||||
'email',
|
||||
'website_url',
|
||||
'logo_li_json',
|
||||
'media_li_json',
|
||||
'social_li_json',
|
||||
'address_li_json',
|
||||
'contact_li_json',
|
||||
'guest_li_json',
|
||||
'level_num',
|
||||
'level_str',
|
||||
'amount',
|
||||
'questions_li_json',
|
||||
'agree',
|
||||
'comments',
|
||||
'staff_notes',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
];
|
||||
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__sponsorship_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'sponsorship',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Sponsorship-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') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 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 as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 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 ?? '';
|
||||
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-03-29
|
||||
@@ -38,7 +224,7 @@ async function load_ae_obj_id__sponsorship_cfg(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_cfg_obj_get_result) {
|
||||
.then(async function (sponsorship_cfg_obj_get_result) {
|
||||
if (sponsorship_cfg_obj_get_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
|
||||
@@ -46,11 +232,28 @@ async function load_ae_obj_id__sponsorship_cfg(
|
||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
|
||||
}
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__sponsorship_cfg({
|
||||
obj_type: 'sponsorship_cfg',
|
||||
obj_li: [sponsorship_cfg_obj_get_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
|
||||
obj_li: [sponsorship_cfg_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_sponsorships,
|
||||
table_name: 'cfg',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_sponsorship_cfg,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return sponsorship_cfg_obj_get_result;
|
||||
} else {
|
||||
@@ -99,7 +302,7 @@ async function load_ae_obj_id__sponsorship(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_obj_get_result) {
|
||||
.then(async function (sponsorship_obj_get_result) {
|
||||
if (sponsorship_obj_get_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
|
||||
@@ -107,11 +310,28 @@ async function load_ae_obj_id__sponsorship(
|
||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`, sponsorship_obj_get_result);
|
||||
}
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__sponsorship({
|
||||
obj_type: 'sponsorship',
|
||||
obj_li: [sponsorship_obj_get_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__sponsorship_props({
|
||||
obj_li: [sponsorship_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_sponsorships,
|
||||
table_name: 'sponsorship',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_sponsorship,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return sponsorship_obj_get_result;
|
||||
} else {
|
||||
@@ -182,13 +402,31 @@ async function load_ae_obj_li__sponsorship(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_obj_li_get_result) {
|
||||
.then(async function (sponsorship_obj_li_get_result) {
|
||||
if (sponsorship_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__sponsorship({
|
||||
obj_type: 'sponsorship',
|
||||
obj_li: sponsorship_obj_li_get_result
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__sponsorship_props({
|
||||
obj_li: sponsorship_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...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_sponsorships,
|
||||
table_name: 'sponsorship',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_sponsorship,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return sponsorship_obj_li_get_result;
|
||||
} else {
|
||||
@@ -205,7 +443,7 @@ async function load_ae_obj_li__sponsorship(
|
||||
|
||||
|
||||
|
||||
async function handle_download_export__sponsorship(
|
||||
export async function download_export__sponsorship(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
@@ -252,91 +490,7 @@ return ae_promises.download__sponsorship_export_file;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-01-15
|
||||
export function db_save_ae_obj_li__sponsorship(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__sponsorship() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_sponsorships.sponsorship.put({
|
||||
id: obj.sponsorship_id_random,
|
||||
sponsorship_id: obj.sponsorship_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_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,
|
||||
|
||||
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}`,
|
||||
|
||||
// From SQL view
|
||||
sponsorship_comment_count: obj.sponsorship_comment_count,
|
||||
|
||||
// A key value list of the comments
|
||||
// sponsorship_comment_kv: obj.sponsorship_comment_kv,
|
||||
// sponsorship_comment_li: obj.sponsorship_comment_li,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.sponsorship_id_random} or ${id_random}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.sponsorship_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -344,7 +498,6 @@ let export_obj = {
|
||||
load_ae_obj_id__sponsorship_cfg: load_ae_obj_id__sponsorship_cfg,
|
||||
load_ae_obj_id__sponsorship: load_ae_obj_id__sponsorship,
|
||||
load_ae_obj_li__sponsorship: load_ae_obj_li__sponsorship,
|
||||
handle_download_export__sponsorship: handle_download_export__sponsorship,
|
||||
db_save_ae_obj_li__sponsorship: db_save_ae_obj_li__sponsorship
|
||||
download_export__sponsorship: download_export__sponsorship,
|
||||
};
|
||||
export let spons_func = export_obj;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
@@ -340,7 +340,7 @@ async function get_url_cfg(cfg) {
|
||||
}
|
||||
return return_data;
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
.catch(function (error) {
|
||||
console.log(`Base URL: ${base_url} | Endpoint: ${endpoint}`);
|
||||
|
||||
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
|
||||
|
||||
Reference in New Issue
Block a user