Modernize(Events/Sponsorships): Full V3 API Migration and ID Hardening
- API Migration: Refactored Event (Device, Location, Session, Presentation, Presenter, File, Exhibit, BadgeTemplate) and Sponsorship modules to use AE API CRUD V3. - ID Hardening: Ensured all nested collection loads and searches use 'id_random' string identifiers to resolve 404 errors. - Logic Consolidation: Unified property processing via '_process_generic_props'. - Cleanup: Removed redundant '/admin' routes. - Stability: Maintained V2 isolation for IDAA search.
This commit is contained in:
@@ -42,37 +42,10 @@ export const properties_to_save_exhibit_tracking = [
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2'
|
||||
];
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__exhibit_tracking_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event exhibit tracking-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- PROPERTIES TO SAVE ---
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
@@ -98,14 +71,12 @@ export const properties_to_save = [
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2'
|
||||
];
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
@@ -155,7 +126,20 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__exhibit_tracking_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
export async function process_ae_obj__exhibit_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
@@ -166,307 +150,265 @@ export async function process_ae_obj__exhibit_props({
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_exhibit',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event exhibit-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
// Updated 2024-03
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_id__exhibit({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
view = 'default',
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
view?: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit | null> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** [V3] id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__exhibit_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
ae_promises.load__exhibit_obj = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_id,
|
||||
view,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__exhibit_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: [ae_promises.load__exhibit_obj],
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
}
|
||||
} else if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('V3 Request failed.', error);
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
} else {
|
||||
ae_promises.load__exhibit_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__exhibit_obj;
|
||||
return ae_promises.load__exhibit_obj || null;
|
||||
}
|
||||
|
||||
// Updated 2024-03-06
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_li__exhibit({
|
||||
api_cfg,
|
||||
event_id,
|
||||
params = {},
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
order_by_li = [
|
||||
{ priority: 'DESC' },
|
||||
{ sort: 'DESC' },
|
||||
{ name: 'ASC' },
|
||||
{ updated_on: 'DESC' }
|
||||
],
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
event_id: any;
|
||||
params: any;
|
||||
event_id: string;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit[]> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** [V3] for=event:${event_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden';
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {
|
||||
and_in_li: {
|
||||
license_max: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
ae_promises.load__event_exhibit_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
ae_promises.load__event_exhibit_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
enabled,
|
||||
hidden,
|
||||
limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_exhibit_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: ae_promises.load__event_exhibit_obj_li,
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
} else if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('V3 List Request failed.', error);
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_obj_li;
|
||||
return ae_promises.load__event_exhibit_obj_li || [];
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_id__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
view = 'default',
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
view?: string;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
view,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_exhibit_tracking_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [ae_promises.load__event_exhibit_tracking_obj],
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
}
|
||||
} else if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj;
|
||||
return ae_promises.load__event_exhibit_tracking_obj || null;
|
||||
}
|
||||
|
||||
// Updated 2024-03-19
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function load_ae_obj_li__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
params = {},
|
||||
enabled = 'enabled',
|
||||
hidden = 'all',
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
order_by_li = [
|
||||
{ priority: 'DESC' },
|
||||
{ sort: 'DESC' },
|
||||
{ updated_on: 'DESC' }
|
||||
],
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: any;
|
||||
params: any;
|
||||
exhibit_id: string;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: any;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'all';
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: {},
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
enabled,
|
||||
hidden,
|
||||
limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_exhibit_tracking_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: ae_promises.load__event_exhibit_tracking_obj_li,
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
} else if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li;
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li || [];
|
||||
}
|
||||
|
||||
// Updated 2024-03-22
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function create_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
event_badge_id,
|
||||
external_person_id,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
@@ -474,133 +416,102 @@ export async function create_ae_obj__exhibit_tracking({
|
||||
exhibit_id: string;
|
||||
event_badge_id: string;
|
||||
external_person_id: string;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
ae_promises.create__event_exhibit_tracking = await api
|
||||
.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
fields: {
|
||||
event_exhibit_id_random: exhibit_id,
|
||||
event_badge_id_random: event_badge_id,
|
||||
external_person_id: external_person_id
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (obj_create_result) {
|
||||
if (obj_create_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
return obj_create_result;
|
||||
});
|
||||
const result = await api.create_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
fields: {
|
||||
event_exhibit_id_random: exhibit_id,
|
||||
event_badge_id_random: event_badge_id,
|
||||
external_person_id
|
||||
},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
return ae_promises.create__event_exhibit_tracking;
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Updated 2024-03-28
|
||||
// Updated 2026-01-20 to V3
|
||||
export async function update_ae_obj__exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_tracking_id,
|
||||
data,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
data: any;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
ae_promises.update__event_exhibit_tracking = await api
|
||||
.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
fields: data,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (obj_update_result) {
|
||||
if (obj_update_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_update_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
return obj_update_result;
|
||||
});
|
||||
const result = await api.update_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
fields: data,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
return ae_promises.update__event_exhibit_tracking;
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function download_export__event_exhibit_tracking({
|
||||
api_cfg,
|
||||
exhibit_id,
|
||||
file_type = 'CSV', // 'CSV' or 'Excel'
|
||||
return_file = true,
|
||||
filename = 'no_filename.csv',
|
||||
auto_download = false,
|
||||
params = {},
|
||||
file_type = 'CSV',
|
||||
filename = 'exhibit_tracking_export.csv',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_id: string;
|
||||
file_type?: string;
|
||||
return_file?: boolean;
|
||||
filename?: string;
|
||||
auto_download?: boolean;
|
||||
params?: key_val;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
console.log('*** ae_events_functions.js: get_event_exhibit_tracking_export() ***');
|
||||
|
||||
const endpoint = `/event/exhibit/${exhibit_id}/tracking/export`;
|
||||
if (file_type == 'CSV' || file_type == 'Excel') {
|
||||
params['file_type'] = file_type;
|
||||
}
|
||||
params['return_file'] = true;
|
||||
const params = {
|
||||
file_type,
|
||||
return_file: true
|
||||
};
|
||||
|
||||
ae_promises.download__event_exhibit_tracking_export_file = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return await api.get_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params,
|
||||
return_blob: true,
|
||||
filename: filename,
|
||||
auto_download: auto_download,
|
||||
log_lvl: log_lvl
|
||||
filename,
|
||||
auto_download: true,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.download__event_exhibit_tracking_export_file:',
|
||||
ae_promises.download__event_exhibit_tracking_export_file
|
||||
);
|
||||
}
|
||||
return ae_promises.download__event_exhibit_tracking_export_file;
|
||||
}
|
||||
Reference in New Issue
Block a user