Moving things to SK. Added events and sessions.
This commit is contained in:
@@ -41,6 +41,128 @@ async function handle_load_ae_obj_id__event({api_cfg, event_id, try_cache=false}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-05-24
|
||||
async function handle_load_ae_obj_li__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__event() ***`);
|
||||
|
||||
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__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
use_alt_table: false, // 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: {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_li_get_result) {
|
||||
if (event_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
return event_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__event_obj_li:', ae_promises.load__event_obj_li);
|
||||
return ae_promises.load__event_obj_li;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Updated 2024-05-24
|
||||
async function handle_load_ae_obj_li__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__event_session() ***`);
|
||||
|
||||
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__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: false, // 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: {'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_li_get_result) {
|
||||
if (event_session_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result});
|
||||
return event_session_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
|
||||
return ae_promises.load__event_session
|
||||
}
|
||||
|
||||
async function handle_load_ae_obj_id__badge({api_cfg, badge_id, try_cache=false}) {
|
||||
console.log(`*** handle_load_ae_obj_id__badge() *** badge_id=${badge_id}`);
|
||||
|
||||
@@ -180,7 +302,7 @@ async function handle_search__event_badge(
|
||||
external_event_id: any,
|
||||
params: any,
|
||||
try_cache: boolean
|
||||
}
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
|
||||
|
||||
@@ -601,6 +723,62 @@ async function handle_update_ae_obj__exhibit_tracking({api_cfg, exhibit_tracking
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_obj_li and save each one to the DB.
|
||||
function handle_db_save_ae_obj_li__event({obj_type, obj_li}) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__event() ***`);
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj) {
|
||||
// console.log(`ae_obj ${obj_type}:`, obj);
|
||||
|
||||
try {
|
||||
const id_random = await db_events.events.put({
|
||||
id_random: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
code: obj.event_code,
|
||||
|
||||
conference: obj.conference,
|
||||
type: obj.type,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
location_address_json: obj.location_address_json,
|
||||
|
||||
mod_abstracts_json: obj.mod_abstracts_json,
|
||||
mod_badges_json: obj.mod_badges_json,
|
||||
mod_exhibits_json: obj.mod_exhibits_json,
|
||||
mod_pres_mgmt_json: obj.mod_pres_mgmt_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,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.events.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function will loop through the badge_obj_li and save each one to the DB.
|
||||
@@ -808,6 +986,62 @@ function handle_db_save_ae_obj_li__exhibitor_tracking({obj_type, obj_li}) {
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_session_obj_li and save each one to the DB.
|
||||
function handle_db_save_ae_obj_li__event_session({obj_type, obj_li}) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__event_session() ***`);
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj) {
|
||||
// console.log(`ae_obj ${obj_type}:`, obj);
|
||||
|
||||
try {
|
||||
const id_random = await db_events.sessions.put({
|
||||
id_random: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
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,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_session_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_session_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.sessions.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_session_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function handle_download_export__event_exhibit_tracking(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -830,11 +1064,11 @@ async function handle_download_export__event_exhibit_tracking(
|
||||
|
||||
ae_promises.download__event_exhibit_tracking_export_file = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_blob: true,
|
||||
filename: filename,
|
||||
auto_download: auto_download,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_blob: true,
|
||||
filename: filename,
|
||||
auto_download: auto_download,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
@@ -845,9 +1079,14 @@ async function handle_download_export__event_exhibit_tracking(
|
||||
|
||||
let export_obj = {
|
||||
handle_load_ae_obj_id__event: handle_load_ae_obj_id__event,
|
||||
handle_load_ae_obj_li__event: handle_load_ae_obj_li__event,
|
||||
|
||||
handle_load_ae_obj_li__event_session: handle_load_ae_obj_li__event_session,
|
||||
|
||||
handle_load_ae_obj_id__badge: handle_load_ae_obj_id__badge,
|
||||
handle_load_ae_obj_li__badge: handle_load_ae_obj_li__badge,
|
||||
handle_search__event_badge: handle_search__event_badge,
|
||||
|
||||
handle_load_ae_obj_id__exhibit: handle_load_ae_obj_id__exhibit,
|
||||
handle_load_ae_obj_li__exhibit: handle_load_ae_obj_li__exhibit,
|
||||
handle_load_ae_obj_id__exhibit_tracking: handle_load_ae_obj_id__exhibit_tracking,
|
||||
|
||||
Reference in New Issue
Block a user