Work on CRUD v2 API calls. Added sessions without files report.

This commit is contained in:
Scott Idem
2024-08-14 14:05:48 -04:00
parent efedc88ade
commit 0d48362529
7 changed files with 566 additions and 84 deletions

View File

@@ -271,6 +271,97 @@ export async function handle_load_ae_obj_li__event_session(
}
// Updated 2024-08-14
export async function handle_qry__event_session(
{
api_cfg,
event_id,
qry_str,
qry_files,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
event_id: any,
qry_str?: string,
qry_files?: null|boolean,
params?: any,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** handle_qry__event_session() *** event_id=${event_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) {
params_json['qry'] = [
{
type: "AND",
field: "file_count_all",
operator: ">",
value: 0
},
];
} else if (qry_files === false) {
params_json['qry'] = [
{
type: "AND",
field: "file_count_all",
operator: "IS",
value: null
},
];
}
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'event_session',
for_obj_type: 'event',
for_obj_id: event_id,
use_alt_tbl: true, // NOTE: We want to use the alt table for session 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 (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 [];
}
});
if (log_lvl) {
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
}
return ae_promises.load__event_session_obj_li;
}
export async function handle_search__event_session(
{
api_cfg,
@@ -280,6 +371,7 @@ export async function handle_search__event_session(
like_search_qry_str = null,
like_presentation_search_qry_str = null,
like_presenter_search_qry_str = null,
file_count = false, // If true then only show those that have a file count
params = {},
try_cache = true,
log_lvl = 0
@@ -291,6 +383,7 @@ export async function handle_search__event_session(
like_search_qry_str?: null|string,
like_presentation_search_qry_str?: null|string,
like_presenter_search_qry_str?: null|string,
file_count?: boolean,
params?: any,
try_cache?: boolean,
log_lvl?: number
@@ -348,9 +441,9 @@ export async function handle_search__event_session(
params_json['and_qry'] = {};
// if (session_type_code) {
// params_json['and_qry']['session_type_code'] = session_type_code;
// }
if (file_count) {
params_json['and_qry']['file_count'] = file_count;
}
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};