Getting some basic things ready for CHOW 2025

This commit is contained in:
Scott Idem
2025-01-15 16:32:18 -05:00
parent 9dc4540329
commit 6f11820857
8 changed files with 355 additions and 44 deletions

View File

@@ -99,6 +99,10 @@ export async function load_ae_obj_li__archive(
for_obj_type = 'account',
for_obj_id,
inc_content_li = false,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
@@ -108,6 +112,10 @@ export async function load_ae_obj_li__archive(
for_obj_type: string,
for_obj_id: string,
inc_content_li?: boolean,
enabled?: string,
hidden?: string,
limit?: number,
offset?: number,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
@@ -118,10 +126,10 @@ export async function load_ae_obj_li__archive(
console.log(`*** load_ae_obj_li__archive() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 99); // 99
let offset: number = (params.qry__offset ?? 0); // 0
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 99); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};

View File

@@ -40,11 +40,10 @@ export async function load_ae_obj_id__event(
let params = {};
// $events_sess.badges.status_load__event_obj = 'loading';
ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event',
obj_id: event_id, // NOTE: This is the FQDN, not normally the ID.
obj_id: event_id,
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,

View File

@@ -139,11 +139,6 @@ export async function load_ae_obj_li__post(
console.log(`*** load_ae_obj_li__post() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
// if (params.qry__enabled) { enabled = params.qry__enabled; }
// if (params.qry__hidden) { hidden = params.qry__hidden; }
// if (params.qry__limit) { limit = params.qry__limit; }
// if (params.qry__offset) { offset = params.qry__offset; }
let params_json: key_val = {};
// console.log('params_json:', params_json);

View File

@@ -1,6 +1,7 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import type { log } from 'console';
import { db_sponsorships } from "$lib/ae_sponsorships/db_sponsorships";
// import { liveQuery } from "dexie";
// import { db_core } from "$lib/db_core";
@@ -15,27 +16,23 @@ let ae_promises: key_val = {}; // Promise<any>;
// Updated 2024-03-29
async function handle_load_ae_obj_id__sponsorship_cfg(
{
api_cfg,
sponsorship_cfg_id,
try_cache=false,
log_lvl=0
api_cfg,
sponsorship_cfg_id,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any,
sponsorship_cfg_id: string,
try_cache: boolean,
log_lvl: number
api_cfg: any,
sponsorship_cfg_id: string,
try_cache: boolean,
log_lvl: number
}
) {
console.log(`*** handle_load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
if (!api_cfg.account_id) {
console.log(`*ae_func* No account_id found in API config!'`);
return false;
) {
if (log_lvl) {
console.log(`*** handle_load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
}
let params = {};
// ae_loc.hub.sponsorships.qry_status = 'loading';
ae_promises.load__sponsorship_cfg_obj = api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship_cfg',
@@ -48,9 +45,16 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
.then(function (sponsorship_cfg_obj_get_result) {
if (sponsorship_cfg_obj_get_result) {
if (log_lvl) {
console.log(`*ae_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
} else if (log_lvl > 1) {
console.log(`*ae_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
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({
obj_type: 'sponsorship',
obj_li: [sponsorship_obj_get_result]
});
}
return sponsorship_cfg_obj_get_result;
} else {
@@ -62,10 +66,89 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_cfg_obj:', ae_promises.load__sponsorship_cfg_obj);
}
return ae_promises.load__sponsorship_cfg_obj;
}
// Updated 2025-01-15
async function load_ae_obj_li__sponsorship(
{
api_cfg,
for_obj_type = 'account',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
inc_content_li?: boolean,
enabled?: string,
hidden?: string,
limit?: number,
offset?: number,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__sponsorship() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
let params_json: key_val = {};
ae_promises.load__sponsorship_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'sponsorship',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(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
});
}
return sponsorship_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_obj_li:', ae_promises.load__sponsorship_obj_li);
}
return ae_promises.load__sponsorship_obj_li;
}
async function handle_download_export__sponsorship(
{
api_cfg,
@@ -113,8 +196,98 @@ 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;
}
}
let export_obj = {
handle_load_ae_obj_id__sponsorship_cfg: handle_load_ae_obj_id__sponsorship_cfg,
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
};
export let spons_func = export_obj;

View File

@@ -0,0 +1,136 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
// li = list
// kv = key value list
// Updated 202-01-15
export interface Sponsorship {
id: string;
// id_random: string;
sponsorship_id: string;
// sponsorship_id_random: string;
account_id: string;
// account_id_random: string;
organization_id?: null|string;
person_id?: null|string;
poc_person_id?: null|string;
poc_json?: null|string;
name: null|string;
name_override: null|string;
description?: null|string;
email?: null|string;
website_url?: null|string;
// html_text?: null|string;
// thumbnail_url?: null|string;
// picture_url?: null|string;
// video_url?: null|string;
// audio_url?: null|string;
// image_url?: null|string;
// document_url?: null|string;
// logo_url?: null|string;
logo_li_json?: null|string;
media_li_json?: null|string;
social_li_json?: null|string;
address_li_json?: null|string;
contact_li_json?: null|string;
guest_li_json?: null|string;
level_num?: null|number;
level_str?: null|string;
amount?: null|number; // In dollars
questions_li_json?: null|string;
agree?: null|boolean; // Catchall agree or consent
comments?: null|string; // From the sponsor
staff_notes?: null|string; // Internal use; from staff
enable: null|boolean;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on?: null|Date;
// Generated fields for sorting locally only
tmp_sort_1?: null|string;
tmp_sort_2?: null|string;
// Additional fields for convenience (database views)
}
// // Updated 2024-11-13
// export interface Sponsorship_Comment {
// id: string;
// // id_random: string;
// sponsorship_comment_id: string;
// // sponsorship_comment_id_random: string;
// sponsorship_id: string;
// // sponsorship_id_random: string;
// external_person_id?: null|string; // For IDAA this is the Novi UUID
// name: null|string;
// title: null|string;
// // summary?: null|string;
// content?: null|string;
// anonymous?: null|boolean;
// full_name?: null|string;
// email?: null|string;
// notify?: null|boolean;
// linked_li_json?: null|string;
// cfg_json?: null|key_val;
// enable: null|boolean;
// hide?: null|boolean;
// priority?: null|boolean
// sort?: null|number;
// group?: null|string;
// notes?: null|string;
// created_on: Date;
// updated_on?: null|Date;
// // Additional fields for convenience (database views)
// }
// Updated 2024-09-25
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
sponsorship!: Table<Sponsorship>;
// comment!: Table<Sponsorship_Comment>;
constructor() {
super('ae_sponsorships_db');
this.version(1).stores({
sponsorship: `
id, sponsorship_id,
account_id,
poc_person_id,
name, name_override,
level_num, level_str, amount,
agree,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
});
}
}
export const db_sponsorships = new MySubClassedDexie();

View File

@@ -1,10 +1,9 @@
/** @type {import('./$types').LayoutLoad} */
console.log(`ae_events_speakers +layout.ts start`);
// import { get } from 'svelte/store';
// import { browser } from '$app/environment';
// import { api } from '$lib/api';
// import type { key_val } from '$lib/ae_stores';
// import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions';
// import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
@@ -17,12 +16,12 @@ export async function load({ parent }) {
let account_id = data.account_id;
let ae_acct = data[account_id];
console.log(`ae_acct = `, ae_acct);
// console.log(`ae_acct = `, ae_acct);
if (!account_id) {
console.log(`events_speakers +layout.ts: The account_id was not found in the data!!!`);
return false;
}
// if (!account_id) {
// console.log(`events_speakers +layout.ts: The account_id was not found in the data!!!`);
// return false;
// }
let event_id = ae_acct.slct.event_id;
if (!event_id) {

View File

@@ -30,10 +30,13 @@ export async function load({ fetch, params, parent }) { // route
for_obj_type: 'account',
for_obj_id: account_id,
inc_content_li: true,
enabled: 'enabled',
hidden: 'not_hidden',
limit: 20,
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'},
params: {qry__enabled: 'enabled', qry__hidden: 'not_hidden', qry__limit: 20},
params: params,
try_cache: true,
log_lvl: log_lvl
log_lvl: 2
});
console.log(`load_event_obj_li = `, load_event_obj_li);
ae_acct.slct.event_obj_li = load_event_obj_li;

View File

@@ -1,11 +1,9 @@
/** @type {import('./$types').LayoutLoad} */
console.log(`ae_sponsorships +layout.ts start`);
// import { get } from 'svelte/store';
// import { browser } from '$app/environment';
// import type { key_val } from '$lib/ae_stores';
// import { api } from '$lib/api';
// import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { spons_func } from '$lib/ae_sponsorships/ae_sponsorships_functions';
@@ -19,10 +17,10 @@ export async function load({ parent }) {
let ae_acct = data[account_id];
// console.log(`ae_acct = `, ae_acct);
if (!account_id) {
console.log(`sponsorships +layout.ts: The account_id was not found in the data!!!`);
return false;
}
// if (!account_id) {
// console.log(`sponsorships +layout.ts: The account_id was not found in the data!!!`);
// return false;
// }
let sponsorship_cfg_id = ae_acct.slct.sponsorship_cfg_id;
if (!sponsorship_cfg_id) {