Wrapping up for the day/week. It is my birthday weekend!

This commit is contained in:
Scott Idem
2024-08-09 19:01:45 -04:00
parent 9a1995dd9f
commit d7dfef4fe0
10 changed files with 240 additions and 57 deletions

View File

@@ -3,6 +3,9 @@ import { api } from '$lib/api';
import { db_events } from "$lib/db_events";
import { handle_load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
import { handle_load_ae_obj_li__event_session } from './ae_events__event_session';
let ae_promises: key_val = {};
@@ -11,11 +14,15 @@ export async function handle_load_ae_obj_id__event_location(
{
api_cfg,
event_location_id,
inc_file_li = false,
inc_session_li = false,
try_cache=true,
log_lvl=0
}: {
api_cfg: any,
event_location_id: string,
inc_file_li?: boolean,
inc_session_li?: boolean,
try_cache?: boolean,
log_lvl?: number
}
@@ -53,6 +60,71 @@ export async function handle_load_ae_obj_id__event_location(
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__event_location_obj:', ae_promises.load__event_location_obj);
}
if (inc_file_li) {
// Load the files for the location
if (log_lvl) {
console.log(`Need to load the file list for the location now`);
}
let load_event_file_obj_li = handle_load_ae_obj_li__event_file({
api_cfg: api_cfg,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
params: {qry__enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_file_obj_li) => {
if (log_lvl) {
console.log(`event_file_obj_li = `, event_file_obj_li);
}
return event_file_obj_li;
});
if (log_lvl) {
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
}
ae_promises.load__event_location_obj.event_file_li = load_event_file_obj_li;
}
if (inc_session_li) {
// Load the sessions for the location
if (log_lvl) {
console.log(`Need to load the session list for the location now`);
}
let load_event_session_obj_li = handle_load_ae_obj_li__event_session({
api_cfg: api_cfg,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
params: {qry__enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_session_obj_li) => {
if (log_lvl) {
console.log(`event_session_obj_li = `, event_session_obj_li);
}
// if (try_cache) {
// console.log(`ae_promises.load__event_session_obj = `, ae_promises.load__event_session_obj);
// ae_promises.load__event_session_obj.event_session_li = event_session_obj_li;
// // Re-save the session object with the new session list
// handle_db_save_ae_obj_li__event_session({
// obj_type: 'event_session',
// obj_li: [ae_promises.load__event_session_obj]
// });
// }
return event_session_obj_li;
});
if (log_lvl) {
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
}
ae_promises.load__event_location_obj.event_session_li = load_event_session_obj_li;
}
return ae_promises.load__event_location_obj;
}
@@ -62,21 +134,25 @@ export async function handle_load_ae_obj_li__event_location(
{
api_cfg,
event_id,
inc_file_li = false,
inc_session_li = false,
params={},
try_cache=true,
log_lvl=0
}: {
api_cfg: any,
event_id: string,
inc_file_li?: boolean,
inc_session_li?: boolean,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** handle_load_ae_obj_li__event_location() ***`);
console.log(`*** handle_load_ae_obj_li__event_location() *** 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
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 99); // 99
let offset: number = (params.qry__offset ?? 0); // 0
@@ -120,6 +196,67 @@ export async function handle_load_ae_obj_li__event_location(
if (log_lvl) {
console.log('ae_promises.load__event_location_obj_li:', ae_promises.load__event_location_obj_li);
}
if (inc_file_li) {
// Load the files for the locations
if (log_lvl) {
console.log(`Need to load the file list for each location now`);
}
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
let event_location_obj = ae_promises.load__event_location_obj_li[i];
let event_location_id = event_location_obj.event_location_id_random;
let load_event_file_obj_li = handle_load_ae_obj_li__event_file({
api_cfg: api_cfg,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
params: {qry__enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_file_obj_li) => {
if (log_lvl) {
console.log(`event_file_obj_li = `, event_file_obj_li);
}
return event_file_obj_li;
});
if (log_lvl) {
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
}
}
}
if (inc_session_li) {
// Load the sessions for the locations
if (log_lvl) {
console.log(`Need to load the session list for each location now`);
}
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
let event_location_obj = ae_promises.load__event_location_obj_li[i];
let event_location_id = event_location_obj.event_location_id_random;
let load_event_session_obj_li = handle_load_ae_obj_li__event_session({
api_cfg: api_cfg,
for_obj_type: 'event_location',
for_obj_id: event_location_id,
params: {qry__enabled: 'all', qry__limit: 100},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_session_obj_li) => {
if (log_lvl) {
console.log(`event_session_obj_li = `, event_session_obj_li);
}
return event_session_obj_li;
});
if (log_lvl) {
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
}
}
}
return ae_promises.load__event_location_obj_li;
}

View File

@@ -248,15 +248,15 @@ export async function handle_load_ae_obj_li__event_session(
if (log_lvl) {
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
}
if (try_cache) {
console.log(`event_session_obj = `, event_session_obj);
event_session_obj.event_presentation_li = event_presentation_obj_li;
// Re-save the session object with the new presentation list
handle_db_save_ae_obj_li__event_session({
obj_type: 'event_session',
obj_li: event_session_obj
});
}
// if (try_cache) {
// console.log(`event_session_obj = `, event_session_obj);
// event_session_obj.event_presentation_li = event_presentation_obj_li;
// // Re-save the session object with the new presentation list
// handle_db_save_ae_obj_li__event_session({
// obj_type: 'event_session',
// obj_li: event_session_obj
// });
// }
return event_presentation_obj_li;
});

View File

@@ -265,6 +265,8 @@ export interface Location {
external_id?: null|string;
code?: null|string;
type_code?: string;
event_id: string;
event_id_random: string;
@@ -317,7 +319,7 @@ export interface Session {
for_id: string;
for_id_random: string;
type_code: string;
type_code?: string;
event_id: string;
event_id_random: string;