More work to prepare the new Archives, Posts, and Recovery Meetings
This commit is contained in:
@@ -196,6 +196,61 @@ export async function load_ae_obj_li__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__archive(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__archive = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_obj_create_result) {
|
||||
if (archive_obj_create_result) {
|
||||
db_save_ae_obj_li__archive(
|
||||
{
|
||||
obj_type: 'archive',
|
||||
obj_li: [archive_obj_create_result]
|
||||
});
|
||||
return archive_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__archive:', ae_promises.create__archive);
|
||||
}
|
||||
return ae_promises.create__archive;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__archive(
|
||||
{
|
||||
@@ -220,7 +275,7 @@ export async function update_ae_obj__archive(
|
||||
ae_promises.update__archive_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
obj_id: archive_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
@@ -368,141 +423,141 @@ export async function qry__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function search__archive(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
poc_agree = null,
|
||||
fulltext_search_qry_str,
|
||||
ft_content_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
file_count = false, // If true then only show those that have a file count
|
||||
person_name = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: any,
|
||||
poc_agree?: null|boolean,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_content_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
file_count?: boolean,
|
||||
person_name?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** search__archive() *** account_id=${account_id}`);
|
||||
// // Updated 2024-09-25
|
||||
// export async function search__archive(
|
||||
// {
|
||||
// api_cfg,
|
||||
// account_id,
|
||||
// poc_agree = null,
|
||||
// fulltext_search_qry_str,
|
||||
// ft_content_search_qry_str,
|
||||
// like_search_qry_str = null,
|
||||
// file_count = false, // If true then only show those that have a file count
|
||||
// person_name = null,
|
||||
// params = {},
|
||||
// try_cache = true,
|
||||
// log_lvl = 0
|
||||
// }: {
|
||||
// api_cfg: any,
|
||||
// account_id: any,
|
||||
// poc_agree?: null|boolean,
|
||||
// fulltext_search_qry_str?: null|string,
|
||||
// ft_content_search_qry_str?: null|string,
|
||||
// like_search_qry_str?: null|string,
|
||||
// file_count?: boolean,
|
||||
// person_name?: null|string,
|
||||
// params?: any,
|
||||
// try_cache?: boolean,
|
||||
// log_lvl?: number
|
||||
// }
|
||||
// ) {
|
||||
// console.log(`*** search__archive() *** account_id=${account_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 ?? 25); // 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 ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
// let params_json: key_val = {};
|
||||
|
||||
// if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
// console.log('No search string provided!!!');
|
||||
// return false; // Returning false instead of [] because no search was performed.
|
||||
// }
|
||||
// // if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
// // console.log('No search string provided!!!');
|
||||
// // return false; // Returning false instead of [] because no search was performed.
|
||||
// // }
|
||||
|
||||
if (fulltext_search_qry_str || ft_content_search_qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
}
|
||||
// if (fulltext_search_qry_str || ft_content_search_qry_str) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
// }
|
||||
|
||||
if (ft_content_search_qry_str && ft_content_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['archive_content_li_qry_str'] = ft_content_search_qry_str;
|
||||
}
|
||||
}
|
||||
// if (ft_content_search_qry_str && ft_content_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['archive_content_li_qry_str'] = ft_content_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_content_search_qry_str) {
|
||||
// params_json['and_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
// // Use the AND (AND LIKE) query
|
||||
// // if (like_search_qry_str || like_content_search_qry_str) {
|
||||
// // params_json['and_like'] = {};
|
||||
// // if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// // }
|
||||
// // if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
if (like_search_qry_str || like_content_search_qry_str || like_content_search_qry_str) {
|
||||
params_json['or_like'] = {};
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
}
|
||||
if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
params_json['or_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
}
|
||||
if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
params_json['or_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
}
|
||||
}
|
||||
// // Use the AND (OR LIKE) query
|
||||
// if (like_search_qry_str || like_content_search_qry_str || like_content_search_qry_str) {
|
||||
// params_json['or_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
// }
|
||||
// if (like_content_search_qry_str && like_content_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['archive_content_li_qry_str'] = like_content_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
if (poc_agree) {
|
||||
params_json['and_qry']['poc_agree'] = poc_agree;
|
||||
}
|
||||
// if (poc_agree) {
|
||||
// params_json['and_qry']['poc_agree'] = poc_agree;
|
||||
// }
|
||||
|
||||
if (file_count) {
|
||||
params_json['and_qry']['file_count'] = file_count;
|
||||
}
|
||||
// if (file_count) {
|
||||
// params_json['and_qry']['file_count'] = file_count;
|
||||
// }
|
||||
|
||||
// This should be using a like with surrounded by %'s
|
||||
if (person_name) {
|
||||
params_json['and_qry']['archive_full_name'] = person_name;
|
||||
}
|
||||
// // This should be using a like with surrounded by %'s
|
||||
// if (person_name) {
|
||||
// params_json['and_qry']['archive_full_name'] = person_name;
|
||||
// }
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
// let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__archive_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for archive searching
|
||||
use_alt_base: 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 (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
|
||||
});
|
||||
}
|
||||
return archive_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
// ae_promises.load__archive_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: 'archive',
|
||||
// for_obj_type: 'account',
|
||||
// for_obj_id: account_id,
|
||||
// use_alt_table: true, // NOTE: We want to use the alt table for archive searching
|
||||
// use_alt_base: 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 (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
|
||||
// });
|
||||
// }
|
||||
// return archive_obj_li_get_result;
|
||||
// } else {
|
||||
// return [];
|
||||
// }
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('No results returned or failed.', error);
|
||||
// })
|
||||
// .finally(function () {
|
||||
// });
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__archive_obj_li:', ae_promises.load__archive_obj_li);
|
||||
}
|
||||
return ae_promises.load__archive_obj_li;
|
||||
}
|
||||
// if (log_lvl) {
|
||||
// console.log('ae_promises.load__archive_obj_li:', ae_promises.load__archive_obj_li);
|
||||
// }
|
||||
// return ae_promises.load__archive_obj_li;
|
||||
// }
|
||||
|
||||
|
||||
// This function will loop through the archive_obj_li and save each one to the DB.
|
||||
|
||||
@@ -183,13 +183,69 @@ export async function create_ae_obj__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
archive_content_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_content_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__archive_content_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
obj_id: archive_content_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_content_obj_update_result) {
|
||||
if (archive_content_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive_content({
|
||||
obj_type: 'archive_content', obj_li: [archive_content_obj_update_result]
|
||||
});
|
||||
}
|
||||
return archive_content_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__archive_content_obj:', ae_promises.update__archive_content_obj);
|
||||
}
|
||||
return ae_promises.update__archive_content_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the archive_content_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__archive_content(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl=0
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
|
||||
36
src/lib/ae_archives_functions.ts
Normal file
36
src/lib/ae_archives_functions.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// This file is used to export all the functions that are used for Aether Posts related functions.
|
||||
|
||||
import {
|
||||
load_ae_obj_id__archive,
|
||||
load_ae_obj_li__archive,
|
||||
create_ae_obj__archive,
|
||||
update_ae_obj__archive,
|
||||
// qry__archive,
|
||||
db_save_ae_obj_li__archive,
|
||||
} from "$lib/ae_archives__archive";
|
||||
|
||||
|
||||
import {
|
||||
load_ae_obj_id__archive_content,
|
||||
load_ae_obj_li__archive_content,
|
||||
create_ae_obj__archive_content,
|
||||
update_ae_obj__archive_content,
|
||||
// qry__archive_content,
|
||||
db_save_ae_obj_li__archive_content,
|
||||
} from "$lib/ae_archives__archive_content";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__archive: load_ae_obj_id__archive,
|
||||
load_ae_obj_li__archive: load_ae_obj_li__archive,
|
||||
create_ae_obj__archive: create_ae_obj__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,
|
||||
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;
|
||||
@@ -214,7 +214,7 @@ export async function load_ae_obj_li__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -244,7 +244,7 @@ export async function load_ae_obj_li__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 100},
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -440,13 +440,69 @@ export async function create_ae_obj__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_location() *** event_location_id=${event_location_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_location_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_location_obj_update_result) {
|
||||
if (event_location_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_location_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_location_obj:', ae_promises.update__event_location_obj);
|
||||
}
|
||||
return ae_promises.update__event_location_obj;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
|
||||
@@ -222,6 +222,62 @@ export async function create_ae_obj__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
event_presentation_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_presentation_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_presentation() *** event_presentation_id=${event_presentation_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_presentation_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presentation',
|
||||
obj_id: event_presentation_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_presentation_obj_update_result) {
|
||||
if (event_presentation_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_presentation({
|
||||
obj_type: 'event_presentation', obj_li: [event_presentation_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_presentation_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_presentation_obj:', ae_promises.update__event_presentation_obj);
|
||||
}
|
||||
return ae_promises.update__event_presentation_obj;
|
||||
}
|
||||
|
||||
|
||||
// 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(
|
||||
|
||||
@@ -268,7 +268,7 @@ export async function update_ae_obj__event_presenter(
|
||||
ae_promises.update__event_presenter_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presenter',
|
||||
obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
obj_id: event_presenter_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
|
||||
@@ -283,6 +283,60 @@ export async function load_ae_obj_li__event_session(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_session() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_session = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_create_result) {
|
||||
if (event_session_obj_create_result) {
|
||||
db_save_ae_obj_li__event_session(
|
||||
{
|
||||
obj_type: 'event_session',
|
||||
obj_li: [event_session_obj_create_result]
|
||||
});
|
||||
return event_session_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_session:', ae_promises.create__event_session);
|
||||
}
|
||||
return ae_promises.create__event_session;
|
||||
}
|
||||
|
||||
// Updated 2024-09-13
|
||||
export async function update_ae_obj__event_session(
|
||||
{
|
||||
@@ -308,7 +362,7 @@ export async function update_ae_obj__event_session(
|
||||
ae_promises.update__event_session_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
obj_id: event_session_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
obj_id: event_session_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
|
||||
646
src/lib/ae_notes__note.ts
Normal file
646
src/lib/ae_notes__note.ts
Normal file
@@ -0,0 +1,646 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_notes } from "$lib/db_notes";
|
||||
|
||||
// import { load_ae_obj_li__note_other } from "$lib/ae_notes__note_other";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
// inc_other_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: string,
|
||||
// inc_other_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__note() *** note_id=${note_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__note_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
obj_id: note_id, // NOTE: This is the FQDN, not normally the 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,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_get_result) {
|
||||
if (note_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: [note_obj_get_result]
|
||||
});
|
||||
}
|
||||
return note_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj:', ae_promises.load__note_obj);
|
||||
}
|
||||
|
||||
// if (inc_other_li) {
|
||||
// // Load the others for the note
|
||||
// if (log_lvl) {
|
||||
// console.log(`Need to load the other list for the note now`);
|
||||
// }
|
||||
// let load_note_other_obj_li = load_ae_obj_li__note_other({
|
||||
// api_cfg: api_cfg,
|
||||
// for_obj_type: 'note',
|
||||
// for_obj_id: note_id,
|
||||
// inc_other_li: inc_other_li,
|
||||
// params: {qry__enabled: 'all', qry__limit: 25},
|
||||
// try_cache: try_cache,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then((note_other_obj_li) => {
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, note_other_obj_li);
|
||||
// }
|
||||
// return note_other_obj_li;
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, load_note_other_obj_li);
|
||||
// }
|
||||
// ae_promises.load__note_obj.note_other_li = load_note_other_obj_li;
|
||||
// }
|
||||
|
||||
return ae_promises.load__note_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__note(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
// inc_other_li = false,
|
||||
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_other_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__note() *** 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 params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_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
|
||||
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 (note_obj_li_get_result) {
|
||||
if (note_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: note_obj_li_get_result
|
||||
});
|
||||
}
|
||||
return note_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
}
|
||||
|
||||
// if (inc_other_li) {
|
||||
// // Load the others for the notes
|
||||
// if (log_lvl) {
|
||||
// console.log(`Need to load the other list for each note now`);
|
||||
// }
|
||||
// for (let i = 0; i < ae_promises.load__note_obj_li.length; i++) {
|
||||
// let note_obj = ae_promises.load__note_obj_li[i];
|
||||
// let note_id = note_obj.note_id_random;
|
||||
|
||||
// let load_note_other_obj_li = load_ae_obj_li__note_other({
|
||||
// api_cfg: api_cfg,
|
||||
// for_obj_type: 'note',
|
||||
// for_obj_id: note_id,
|
||||
// params: {qry__enabled: enabled, qry__limit: limit},
|
||||
// try_cache: try_cache,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then((note_other_obj_li) => {
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, note_other_obj_li);
|
||||
// }
|
||||
|
||||
// return note_other_obj_li;
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log(`load_note_other_obj_li = `, load_note_other_obj_li);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return ae_promises.load__note_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__note(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__note() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__note = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_create_result) {
|
||||
if (note_obj_create_result) {
|
||||
db_save_ae_obj_li__note(
|
||||
{
|
||||
obj_type: 'note',
|
||||
obj_li: [note_obj_create_result]
|
||||
});
|
||||
return note_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__note:', ae_promises.create__note);
|
||||
}
|
||||
return ae_promises.create__note;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__note() *** note_id=${note_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__note_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
obj_id: note_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_update_result) {
|
||||
if (note_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note', obj_li: [note_obj_update_result]
|
||||
});
|
||||
}
|
||||
return note_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__note_obj:', ae_promises.update__note_obj);
|
||||
}
|
||||
return ae_promises.update__note_obj;
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2024-09-25
|
||||
export async function qry__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
qry_str,
|
||||
qry_files,
|
||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: any,
|
||||
qry_str?: string,
|
||||
qry_files?: null|boolean,
|
||||
qry_start_datetime?: null|string, // Greater than this datetime
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry__note() *** note_id=${note_id} qry_str=${qry_str}`);
|
||||
|
||||
// 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 ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// if (qry_str && qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
// }
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_files === true) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: ">",
|
||||
value: 0
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
} else if (qry_files === false) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: "IS",
|
||||
value: null
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_start_datetime) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "start_datetime",
|
||||
operator: ">",
|
||||
value: qry_start_datetime
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: note_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for note searching
|
||||
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 (note_obj_li_get_result) {
|
||||
if (note_obj_li_get_result) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: note_obj_li_get_result
|
||||
});
|
||||
return note_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
}
|
||||
return ae_promises.load__note_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// export async function search__note(
|
||||
// {
|
||||
// api_cfg,
|
||||
// account_id,
|
||||
// poc_agree = null,
|
||||
// fulltext_search_qry_str,
|
||||
// ft_other_search_qry_str,
|
||||
// like_search_qry_str = null,
|
||||
// file_count = false, // If true then only show those that have a file count
|
||||
// person_name = null,
|
||||
// params = {},
|
||||
// try_cache = true,
|
||||
// log_lvl = 0
|
||||
// }: {
|
||||
// api_cfg: any,
|
||||
// account_id: any,
|
||||
// poc_agree?: null|boolean,
|
||||
// fulltext_search_qry_str?: null|string,
|
||||
// ft_other_search_qry_str?: null|string,
|
||||
// like_search_qry_str?: null|string,
|
||||
// file_count?: boolean,
|
||||
// person_name?: null|string,
|
||||
// params?: any,
|
||||
// try_cache?: boolean,
|
||||
// log_lvl?: number
|
||||
// }
|
||||
// ) {
|
||||
// console.log(`*** search__note() *** account_id=${account_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 ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
// let params_json: key_val = {};
|
||||
|
||||
// // if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
// // console.log('No search string provided!!!');
|
||||
// // return false; // Returning false instead of [] because no search was performed.
|
||||
// // }
|
||||
|
||||
// if (fulltext_search_qry_str || ft_other_search_qry_str) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
// }
|
||||
|
||||
// if (ft_other_search_qry_str && ft_other_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['note_other_li_qry_str'] = ft_other_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Use the AND (AND LIKE) query
|
||||
// // if (like_search_qry_str || like_other_search_qry_str) {
|
||||
// // params_json['and_like'] = {};
|
||||
// // if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// // }
|
||||
// // if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // Use the AND (OR LIKE) query
|
||||
// if (like_search_qry_str || like_other_search_qry_str || like_other_search_qry_str) {
|
||||
// params_json['or_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// }
|
||||
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
// if (poc_agree) {
|
||||
// params_json['and_qry']['poc_agree'] = poc_agree;
|
||||
// }
|
||||
|
||||
// if (file_count) {
|
||||
// params_json['and_qry']['file_count'] = file_count;
|
||||
// }
|
||||
|
||||
// // This should be using a like with surrounded by %'s
|
||||
// if (person_name) {
|
||||
// params_json['and_qry']['note_full_name'] = person_name;
|
||||
// }
|
||||
|
||||
// let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
// ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: 'note',
|
||||
// for_obj_type: 'account',
|
||||
// for_obj_id: account_id,
|
||||
// use_alt_table: true, // NOTE: We want to use the alt table for note searching
|
||||
// use_alt_base: 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 (note_obj_li_get_result) {
|
||||
// if (note_obj_li_get_result) {
|
||||
// if (try_cache) {
|
||||
// db_save_ae_obj_li__note({
|
||||
// obj_type: 'note',
|
||||
// obj_li: note_obj_li_get_result
|
||||
// });
|
||||
// }
|
||||
// return note_obj_li_get_result;
|
||||
// } else {
|
||||
// return [];
|
||||
// }
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('No results returned or failed.', error);
|
||||
// })
|
||||
// .finally(function () {
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
// }
|
||||
// return ae_promises.load__note_obj_li;
|
||||
// }
|
||||
|
||||
|
||||
// This function will loop through the note_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__note(
|
||||
{
|
||||
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__note() ***`);
|
||||
}
|
||||
|
||||
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_notes.note.put({
|
||||
id: obj.note_id_random,
|
||||
note_id: obj.note_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
outline: obj.outline,
|
||||
|
||||
// note: obj.note,
|
||||
note_html: obj.note_html,
|
||||
note_json: obj.note_json,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
|
||||
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
|
||||
// note_other_count: obj.note_other_count,
|
||||
|
||||
// A key value list of the others
|
||||
// note_other_kv: obj.note_other_kv,
|
||||
// note_other_li: obj.note_other_li,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.note_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.note_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_notes.note.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.note_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,20 @@
|
||||
// This file is used to export all the functions that are used for Aether Events related functions.
|
||||
|
||||
// import {
|
||||
// handle_load_ae_obj_id__note,
|
||||
// handle_load_ae_obj_li__note,
|
||||
// handle_db_save_ae_obj_li__note,
|
||||
// } from "$lib/ae_notes__note";
|
||||
|
||||
import {
|
||||
load_ae_obj_id__note,
|
||||
load_ae_obj_li__note,
|
||||
create_ae_obj__note,
|
||||
update_ae_obj__note,
|
||||
// qry__note,
|
||||
db_save_ae_obj_li__note,
|
||||
} from "$lib/ae_notes__note";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
// handle_load_ae_obj_id__note: handle_load_ae_obj_id__note,
|
||||
load_ae_obj_id__note: load_ae_obj_id__note,
|
||||
load_ae_obj_li__note: load_ae_obj_li__note,
|
||||
create_ae_obj__note: create_ae_obj__note,
|
||||
update_ae_obj__note: update_ae_obj__note,
|
||||
db_save_ae_obj_li__note: db_save_ae_obj_li__note,
|
||||
};
|
||||
export let notes_func = export_obj;
|
||||
|
||||
@@ -69,7 +69,6 @@ export async function load_ae_obj_id__post(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'post',
|
||||
for_obj_id: post_id,
|
||||
inc_comment_li: inc_comment_li,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
@@ -196,6 +195,61 @@ export async function load_ae_obj_li__post(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__post(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__post() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__post = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_obj_create_result) {
|
||||
if (post_obj_create_result) {
|
||||
db_save_ae_obj_li__post(
|
||||
{
|
||||
obj_type: 'post',
|
||||
obj_li: [post_obj_create_result]
|
||||
});
|
||||
return post_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__post:', ae_promises.create__post);
|
||||
}
|
||||
return ae_promises.create__post;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__post(
|
||||
{
|
||||
@@ -220,7 +274,7 @@ export async function update_ae_obj__post(
|
||||
ae_promises.update__post_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
obj_id: post_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
obj_id: post_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
@@ -257,7 +311,7 @@ export async function update_ae_obj__post(
|
||||
export async function qry__post(
|
||||
{
|
||||
api_cfg,
|
||||
post_id,
|
||||
account_id,
|
||||
qry_str,
|
||||
qry_files,
|
||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||
@@ -270,7 +324,7 @@ export async function qry__post(
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_id: any,
|
||||
account_id: any,
|
||||
qry_str?: string,
|
||||
qry_files?: null|boolean,
|
||||
qry_start_datetime?: null|string, // Greater than this datetime
|
||||
@@ -283,7 +337,7 @@ export async function qry__post(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry__post() *** post_id=${post_id} qry_str=${qry_str}`);
|
||||
console.log(`*** qry__post() *** account_id=${account_id} qry_str=${qry_str}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
@@ -335,8 +389,8 @@ export async function qry__post(
|
||||
ae_promises.load__post_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: post_id,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for post searching
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
@@ -533,22 +587,19 @@ export function db_save_ae_obj_li__post(
|
||||
id: obj.post_id_random,
|
||||
post_id: obj.post_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
title: null|string;
|
||||
content?: null|string;
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
sort_by: obj.sort_by,
|
||||
sort_by_desc: obj.sort_by_desc,
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
|
||||
@@ -183,6 +183,62 @@ export async function create_ae_obj__post_comment(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__post_comment_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_update_result) {
|
||||
if (post_comment_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__post_comment({
|
||||
obj_type: 'post_comment', obj_li: [post_comment_obj_update_result]
|
||||
});
|
||||
}
|
||||
return post_comment_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__post_comment_obj:', ae_promises.update__post_comment_obj);
|
||||
}
|
||||
return ae_promises.update__post_comment_obj;
|
||||
}
|
||||
|
||||
|
||||
// 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(
|
||||
|
||||
36
src/lib/ae_posts_functions.ts
Normal file
36
src/lib/ae_posts_functions.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// This file is used to export all the functions that are used for Aether Posts related functions.
|
||||
|
||||
import {
|
||||
load_ae_obj_id__post,
|
||||
load_ae_obj_li__post,
|
||||
create_ae_obj__post,
|
||||
update_ae_obj__post,
|
||||
// qry__post,
|
||||
db_save_ae_obj_li__post,
|
||||
} from "$lib/ae_posts__post";
|
||||
|
||||
|
||||
import {
|
||||
load_ae_obj_id__post_comment,
|
||||
load_ae_obj_li__post_comment,
|
||||
create_ae_obj__post_comment,
|
||||
update_ae_obj__post_comment,
|
||||
// qry__post_comment,
|
||||
db_save_ae_obj_li__post_comment,
|
||||
} from "$lib/ae_posts__post_comment";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__post: load_ae_obj_id__post,
|
||||
load_ae_obj_li__post: load_ae_obj_li__post,
|
||||
create_ae_obj__post: create_ae_obj__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,
|
||||
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;
|
||||
@@ -117,7 +117,7 @@ export interface Archive_Content {
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// We just tell the typing system this is the case
|
||||
archive!: Table<Archive>;
|
||||
archive_content!: Table<Archive_Content>;
|
||||
content!: Table<Archive_Content>;
|
||||
|
||||
constructor() {
|
||||
super('ae_archives_db');
|
||||
@@ -129,7 +129,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
name,
|
||||
original_datetime, original_timezone, original_location,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
archive_content: `
|
||||
content: `
|
||||
id, archive_content_id,
|
||||
archive_id,
|
||||
archive_content_type,
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface Note {
|
||||
note_id: string;
|
||||
|
||||
// Essentially this is a change log of notes
|
||||
snapshot_id: string; // This is the original note ID. If deleted, then delete all children notes.
|
||||
snapshot_id?: string; // This is the original note ID. If deleted, then delete all children notes.
|
||||
previous_id?: null|string; // This is the old or parent note ID
|
||||
next_id?: null|string; // This is the new or child note ID
|
||||
|
||||
@@ -29,8 +29,8 @@ export interface Note {
|
||||
|
||||
account_id?: null|string; // Owner account of the note
|
||||
person_id?: null|string; // Owner person of the note
|
||||
event_id: null|string; // Assign to an event???
|
||||
location_id?: null|string; // Assign to a location???
|
||||
// event_id?: null|string; // Assign to an event???
|
||||
// location_id?: null|string; // Assign to a location???
|
||||
|
||||
name: string; // or the title
|
||||
summary?: null|string; // LLM (AI) generated summary...???
|
||||
@@ -89,7 +89,7 @@ export interface Note {
|
||||
|
||||
// A key value list of the presentations
|
||||
note_presentation_kv?: null|key_val;
|
||||
note_presentation_li?: null|list;
|
||||
note_presentation_li?: null|[];
|
||||
// A key value list of the files
|
||||
note_file_kv?: null|key_val;
|
||||
note_file_li?: null|[];
|
||||
@@ -133,14 +133,13 @@ export class MySubClassedDexie extends Dexie {
|
||||
super('ae_notes_db');
|
||||
this.version(1).stores({
|
||||
note: `
|
||||
id, note_id, note_id_random,
|
||||
id, note_id,
|
||||
code,
|
||||
account_id, account_id_random,
|
||||
account_id,
|
||||
conference, type,
|
||||
name,
|
||||
start_datetime, end_datetime,
|
||||
timezone,
|
||||
cfg_json,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export interface Post_Comment {
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// We just tell the typing system this is the case
|
||||
post!: Table<Post>;
|
||||
post_comment!: Table<Post_Comment>;
|
||||
comment!: Table<Post_Comment>;
|
||||
|
||||
constructor() {
|
||||
super('ae_posts_db');
|
||||
@@ -102,7 +102,8 @@ export class MySubClassedDexie extends Dexie {
|
||||
full_name, email,
|
||||
archive, archive_on,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
post_comment: `
|
||||
|
||||
comment: `
|
||||
id, post_comment_id,
|
||||
post_id,
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user