New reports for large files. Better file query as well.
This commit is contained in:
@@ -275,12 +275,108 @@ export async function update_ae_obj__event_file(
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2024-10-15
|
||||
export async function qry__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
qry_created_on = null, // Example greater than: '2024-10-24'
|
||||
qry_min_file_size = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC', 'filename': 'ASC', 'extension': 'ASC', 'hosted_file_size': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
qry_created_on?: null|string,
|
||||
qry_min_file_size?: null|number,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** qry__event_file() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_created_on) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "created_on",
|
||||
operator: ">",
|
||||
value: qry_created_on
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_min_file_size) {
|
||||
console.log('qry_min_file_size:', qry_min_file_size);
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "hosted_file_size",
|
||||
operator: ">",
|
||||
value: qry_min_file_size
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for file 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_file_obj_li_get_result) {
|
||||
if (event_file_obj_li_get_result) {
|
||||
db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
return event_file_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_file_obj_li:', ae_promises.load__event_file_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_file_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-12
|
||||
export async function search__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
created_on = null,
|
||||
min_file_size = null,
|
||||
fulltext_search_qry_str,
|
||||
ft_file_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
@@ -294,6 +390,7 @@ export async function search__event_file(
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
created_on?: null|string,
|
||||
min_file_size?: null|number,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_file_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
@@ -363,6 +460,10 @@ export async function search__event_file(
|
||||
// params_json['and_qry']['created_on'] = created_on;
|
||||
// }
|
||||
|
||||
if (min_file_size) {
|
||||
params_json['and_qry'] = {'hosted_file_size': {'>': min_file_size}};
|
||||
}
|
||||
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
delete_ae_obj_id__event_file,
|
||||
create_event_file_obj_from_hosted_file_async,
|
||||
update_ae_obj__event_file,
|
||||
qry__event_file,
|
||||
search__event_file,
|
||||
db_save_ae_obj_li__event_file,
|
||||
} from "$lib/ae_events__event_file";
|
||||
@@ -83,6 +84,7 @@ let export_obj = {
|
||||
load_ae_obj_li__event_file: load_ae_obj_li__event_file,
|
||||
delete_ae_obj_id__event_file: delete_ae_obj_id__event_file,
|
||||
update_ae_obj__event_file: update_ae_obj__event_file,
|
||||
qry__event_file: qry__event_file,
|
||||
search__event_file: search__event_file,
|
||||
db_save_ae_obj_li__event_file: db_save_ae_obj_li__event_file,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user