Refactor: Remove redundant db_save exports and complete V3 cleanup
This commit is contained in:
@@ -38,9 +38,7 @@ import { load_ae_obj_li__country_subdivision } from '$lib/ae_core/core__country_
|
||||
import {
|
||||
load_ae_obj_id__hosted_file,
|
||||
load_ae_obj_li__hosted_file,
|
||||
delete_ae_obj_id__hosted_file,
|
||||
db_save_ae_obj_li__hosted_file,
|
||||
db_update_ae_obj_id__hosted_file
|
||||
delete_ae_obj_id__hosted_file
|
||||
} from '$lib/ae_core/core__hosted_files';
|
||||
|
||||
// This has more generic general purpose functions that can eventually replace the custom ones per object type.
|
||||
@@ -512,8 +510,6 @@ const export_obj = {
|
||||
load_ae_obj_id__hosted_file: load_ae_obj_id__hosted_file,
|
||||
load_ae_obj_li__hosted_file: load_ae_obj_li__hosted_file,
|
||||
delete_ae_obj_id__hosted_file: delete_ae_obj_id__hosted_file,
|
||||
db_save_ae_obj_li__hosted_file: db_save_ae_obj_li__hosted_file,
|
||||
db_update_ae_obj_id__hosted_file: db_update_ae_obj_id__hosted_file,
|
||||
|
||||
db_save_ae_obj_li__ae_obj: db_save_ae_obj_li__ae_obj,
|
||||
|
||||
|
||||
@@ -402,6 +402,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7);
|
||||
@@ -413,6 +414,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
|
||||
@@ -5,28 +5,18 @@ 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 type { ae_EventLocation } from '$lib/types/ae_types';
|
||||
|
||||
import { load_ae_obj_li__event_device } from '$lib/ae_events/ae_events__event_device';
|
||||
import { load_ae_obj_li__event_file } from '$lib/ae_events/ae_events__event_file';
|
||||
import { load_ae_obj_li__event_session } from './ae_events__event_session';
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_id__event_location({
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
inc_device_li = false,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
view = 'default',
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
event_location_id: string;
|
||||
inc_device_li?: boolean;
|
||||
inc_file_li?: boolean;
|
||||
inc_session_li?: boolean;
|
||||
view?: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
@@ -35,18 +25,6 @@ export async function load_ae_obj_id__event_location({
|
||||
console.log(`*** load_ae_obj_id__event_location() *** [V3] id=${event_location_id}`);
|
||||
}
|
||||
|
||||
// Check if offline
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) {
|
||||
if (log_lvl) console.log('Browser is offline. Skipping API and attempting cache load.');
|
||||
ae_promises.load__event_location_obj = await db_events.location.get(event_location_id);
|
||||
if (ae_promises.load__event_location_obj) {
|
||||
return await _handle_nested_loads(ae_promises.load__event_location_obj, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__event_location_obj = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
@@ -80,53 +58,7 @@ export async function load_ae_obj_id__event_location({
|
||||
}
|
||||
}
|
||||
|
||||
if (!ae_promises.load__event_location_obj) return null;
|
||||
|
||||
return await _handle_nested_loads(ae_promises.load__event_location_obj, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to handle nested collection loads for a location
|
||||
*/
|
||||
async function _handle_nested_loads(location_obj: any, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl }: any) {
|
||||
const current_location_id = location_obj.event_location_id_random || location_obj.event_location_id || location_obj.id;
|
||||
|
||||
if (inc_device_li) {
|
||||
location_obj.event_device_obj_li = await load_ae_obj_li__event_device({
|
||||
api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
location_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
try_cache,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
if (inc_session_li) {
|
||||
location_obj.event_session_li = await load_ae_obj_li__event_session({
|
||||
api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
try_cache,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return location_obj;
|
||||
return ae_promises.load__event_location_obj || null;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
@@ -134,12 +66,9 @@ export async function load_ae_obj_li__event_location({
|
||||
api_cfg,
|
||||
for_obj_type = 'event',
|
||||
for_obj_id,
|
||||
inc_device_li = false,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
order_by_li = [
|
||||
{ priority: 'DESC' },
|
||||
@@ -153,9 +82,6 @@ export async function load_ae_obj_li__event_location({
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id: string;
|
||||
inc_device_li?: boolean;
|
||||
inc_file_li?: boolean;
|
||||
inc_session_li?: boolean;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
limit?: number;
|
||||
@@ -168,20 +94,6 @@ export async function load_ae_obj_li__event_location({
|
||||
console.log(`*** load_ae_obj_li__event_location() *** [V3] for=${for_obj_type}:${for_obj_id}`);
|
||||
}
|
||||
|
||||
// Check if offline
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) {
|
||||
if (log_lvl) console.log('Browser is offline. Skipping API and attempting cache load.');
|
||||
ae_promises.load__event_location_obj_li = await db_events.location
|
||||
.where('event_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
if (ae_promises.load__event_location_obj_li) {
|
||||
for (const loc of ae_promises.load__event_location_obj_li) {
|
||||
await _handle_nested_loads(loc, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl });
|
||||
}
|
||||
}
|
||||
return ae_promises.load__event_location_obj_li || [];
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
@@ -224,12 +136,6 @@ export async function load_ae_obj_li__event_location({
|
||||
}
|
||||
}
|
||||
|
||||
if (ae_promises.load__event_location_obj_li) {
|
||||
for (const loc of ae_promises.load__event_location_obj_li) {
|
||||
await _handle_nested_loads(loc, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl });
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_location_obj_li || [];
|
||||
}
|
||||
|
||||
@@ -428,17 +334,12 @@ export async function search__event_location({
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_location_id',
|
||||
'event_id',
|
||||
'external_id',
|
||||
'code',
|
||||
'type_code',
|
||||
'event_id',
|
||||
'name',
|
||||
'description',
|
||||
'passcode',
|
||||
'hide_event_launcher',
|
||||
'alert',
|
||||
'alert_msg',
|
||||
'data_json',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
@@ -449,13 +350,12 @@ export const properties_to_save = [
|
||||
'updated_on',
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
'event_name'
|
||||
];
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
@@ -474,6 +374,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7);
|
||||
@@ -485,6 +386,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
|
||||
@@ -365,7 +365,6 @@ export const properties_to_save = [
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
||||
@@ -506,6 +506,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7);
|
||||
@@ -517,6 +518,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
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';
|
||||
@@ -38,7 +37,6 @@ const export_obj = {
|
||||
create_ae_obj__event: event.create_ae_obj__event,
|
||||
delete_ae_obj_id__event: event.delete_ae_obj_id__event,
|
||||
update_ae_obj__event: event.update_ae_obj__event,
|
||||
// db_save_ae_obj_li__event: event.db_save_ae_obj_li__event,
|
||||
sync_config__event_pres_mgmt: event.sync_config__event_pres_mgmt,
|
||||
|
||||
// Event Badges
|
||||
@@ -49,10 +47,6 @@ const export_obj = {
|
||||
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
|
||||
qry__event_badge: event_badge.qry__event_badge,
|
||||
search__event_badge: event_badge.search__event_badge,
|
||||
// handle_load_ae_obj_id__badge: event_badge.handle_load_ae_obj_id__badge,
|
||||
// handle_load_ae_obj_li__badge: event_badge.handle_load_ae_obj_li__badge,
|
||||
// handle_search__event_badge: event_badge.handle_search__event_badge,
|
||||
// db_save_ae_obj_li__event_badge: event_badge.db_save_ae_obj_li__event_badge,
|
||||
|
||||
// Event Badge Templates
|
||||
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
|
||||
@@ -69,7 +63,6 @@ const export_obj = {
|
||||
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
|
||||
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
|
||||
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
|
||||
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
|
||||
|
||||
// Event Exhibits
|
||||
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
||||
@@ -79,7 +72,6 @@ const export_obj = {
|
||||
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,
|
||||
@@ -90,7 +82,6 @@ const export_obj = {
|
||||
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
|
||||
qry__event_file: event_file.qry__event_file,
|
||||
search__event_file: event_file.search__event_file,
|
||||
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
|
||||
|
||||
// Event Locations
|
||||
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
|
||||
@@ -98,7 +89,6 @@ const export_obj = {
|
||||
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
|
||||
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
|
||||
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
|
||||
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
|
||||
|
||||
// Event Sessions
|
||||
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
|
||||
@@ -109,7 +99,6 @@ const export_obj = {
|
||||
qry__event_session: event_session.qry__event_session,
|
||||
search__event_session: event_session.search__event_session,
|
||||
email_sign_in__event_session: event_session.email_sign_in__event_session,
|
||||
// db_save_ae_obj_li__event_session: event_session.db_save_ae_obj_li__event_session,
|
||||
|
||||
// Event Presentations
|
||||
load_ae_obj_id__event_presentation: event_presentation.load_ae_obj_id__event_presentation,
|
||||
@@ -117,7 +106,6 @@ const export_obj = {
|
||||
create_ae_obj__event_presentation: event_presentation.create_ae_obj__event_presentation,
|
||||
delete_ae_obj_id__event_presentation: event_presentation.delete_ae_obj_id__event_presentation,
|
||||
update_ae_obj__event_presentation: event_presentation.update_ae_obj__event_presentation,
|
||||
// db_save_ae_obj_li__event_presentation: event_presentation.db_save_ae_obj_li__event_presentation,
|
||||
|
||||
// Event Presenters
|
||||
load_ae_obj_id__event_presenter: event_presenter.load_ae_obj_id__event_presenter,
|
||||
@@ -126,7 +114,6 @@ const export_obj = {
|
||||
delete_ae_obj_id__event_presenter: event_presenter.delete_ae_obj_id__event_presenter,
|
||||
update_ae_obj__event_presenter: event_presenter.update_ae_obj__event_presenter,
|
||||
search__event_presenter: event_presenter.search__event_presenter,
|
||||
// db_save_ae_obj_li__event_presenter: event_presenter.db_save_ae_obj_li__event_presenter,
|
||||
email_sign_in__event_presenter: event_presenter.email_sign_in__event_presenter
|
||||
};
|
||||
export const events_func = export_obj;
|
||||
export const events_func = export_obj;
|
||||
Reference in New Issue
Block a user