More general code clean up. Improvement to IDB save for Event.

This commit is contained in:
Scott Idem
2025-05-09 14:13:59 -04:00
parent 8f1f7bfa7e
commit dc7da8c930
6 changed files with 34 additions and 18 deletions

View File

@@ -160,7 +160,9 @@ export async function load_ae_obj_li__event(
params_json['and_qry'] = {}; params_json['and_qry'] = {};
} }
console.log('qry_conference is false!'); if (log_lvl) {
console.log('qry_conference is false!');
}
params_json['and_qry']['conference'] = qry_conference; params_json['and_qry']['conference'] = qry_conference;
} }
@@ -504,7 +506,8 @@ export async function update_ae_obj__event(
// This function will loop through the event_obj_li and save each one to the DB. // This function will loop through the event_obj_li and save each one to the DB.
export function db_save_ae_obj_li__event( // Updated 2025-05-09
export async function db_save_ae_obj_li__event(
{ {
obj_type, obj_type,
obj_li, obj_li,
@@ -520,7 +523,9 @@ export function db_save_ae_obj_li__event(
} }
if (obj_li && obj_li.length) { if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) { // let obj_li_id: string[] = [];
for (const obj of obj_li) {
// obj_li.forEach(async function (obj: any) {
if (log_lvl) { if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj); console.log(`ae_obj ${obj_type}:`, obj);
} }
@@ -610,6 +615,8 @@ export function db_save_ae_obj_li__event(
event_file_id_li_json: obj.event_file_id_li_json, event_file_id_li_json: obj.event_file_id_li_json,
}); });
// console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`); // console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`);
// obj_li_id.push(obj_record.id);
} catch (error) { } catch (error) {
let status = `Failed to put ${obj.event_id_random}: ${error}`; let status = `Failed to put ${obj.event_id_random}: ${error}`;
console.log(status); console.log(status);
@@ -617,7 +624,7 @@ export function db_save_ae_obj_li__event(
// const id_random = await db_events.events.put(obj); // const id_random = await db_events.events.put(obj);
// console.log(`Put obj with ID: ${obj.event_id_random}`); // console.log(`Put obj with ID: ${obj.event_id_random}`);
}); }
return true; return true;
} }

View File

@@ -153,8 +153,10 @@ if (!$ae_loc?.site_cfg_json) {
// BEGIN: New Version Check: // BEGIN: New Version Check:
if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) { if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
console.log('ROOT: New version of the ae_loc (core local storage) available!!!'); if (log_lvl) {
console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`); console.log('ROOT: New version of the ae_loc (core local storage) available!!!');
console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
}
flag_clear_idb = true; flag_clear_idb = true;
flag_clear_local = true; flag_clear_local = true;
@@ -496,7 +498,9 @@ if (browser) {
// save_ds_to_local(ae_acct.ds); // save_ds_to_local(ae_acct.ds);
let ae_ds = ae_acct.ds; let ae_ds = ae_acct.ds;
console.log(`ae_ds__ data:`, ae_ds) if (log_lvl) {
console.log(`ae_ds__ data:`, ae_ds);
}
for (let [key, value] of Object.entries(ae_ds)) { for (let [key, value] of Object.entries(ae_ds)) {
console.log(`ae_ds__ key: ${key}, value:`, value); console.log(`ae_ds__ key: ${key}, value:`, value);
localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value)); localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));

View File

@@ -1,5 +1,5 @@
/** @type {import('./$types').LayoutLoad} */ /** @type {import('./$types').LayoutLoad} */
console.log(`IDAA Recovery Meetings - [account_id] +layout.ts start`); // console.log(`IDAA Recovery Meetings - [account_id] +layout.ts start`);
import { error } from '@sveltejs/kit'; import { error } from '@sveltejs/kit';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
@@ -35,7 +35,9 @@ export async function load({ params, parent }) { // route
try_cache: true, try_cache: true,
log_lvl: log_lvl log_lvl: log_lvl
}); });
console.log(`load_event_obj_li = `, load_event_obj_li); if (log_lvl) {
console.log(`load_event_obj_li = `, load_event_obj_li);
}
ae_acct.slct.event_obj_li = load_event_obj_li; ae_acct.slct.event_obj_li = load_event_obj_li;
} }

View File

@@ -170,7 +170,7 @@ $: if ($idaa_trig.event_li_qry) {
search_delay += 50+random_delay; search_delay += 50+random_delay;
} }
log_lvl = 1; log_lvl = 0;
let count = 0; let count = 0;
let request_loop = setInterval(() => { let request_loop = setInterval(() => {

View File

@@ -1,8 +1,9 @@
<script lang="ts"> <script lang="ts">
/** @type {import('./$types').LayoutProps} */ /** @type {import('./$types').LayoutProps} */
let log_lvl: number = 0;
// *** Import Svelte specific // *** Import Svelte specific
import { browser } from '$app/environment'; // import { browser } from '$app/environment';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
// *** Import other supporting libraries // *** Import other supporting libraries
@@ -39,7 +40,9 @@ $journals_loc.qry__offset = 0;
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. // Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
$slct.account_id = data.account_id; $slct.account_id = data.account_id;
console.log(`$slct.account_id = `, $slct.account_id); if (log_lvl) {
console.log(`$slct.account_id = `, $slct.account_id);
}
let ae_acct = data[$slct.account_id]; let ae_acct = data[$slct.account_id];
// console.log(`ae_acct = `, ae_acct); // console.log(`ae_acct = `, ae_acct);
@@ -55,13 +58,13 @@ $journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj; // $journals_slct.journal_obj = ae_acct.slct.journal_obj;
$journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li; $journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
let ae_promises: key_val = {}; // let ae_promises: key_val = {};
if (browser) { // if (browser) {
console.log('AE Journals: +layout.svelte'); // console.log('AE Journals: +layout.svelte');
console.log($journals_slct.journal_obj_li); // console.log($journals_slct.journal_obj_li);
}; // };
</script> </script>

View File

@@ -53,7 +53,7 @@ export async function load({ fetch, parent }) {
limit: 25, limit: 25,
// params: ae_params, // params: ae_params,
try_cache: true, try_cache: true,
log_lvl: 2 log_lvl: log_lvl
}); });
ae_acct.slct.journal_obj_li = load_journal_obj_li; ae_acct.slct.journal_obj_li = load_journal_obj_li;