fixed routine attr validation logic

This commit is contained in:
ModulatingForce 2024-03-28 13:46:02 -04:00
parent c27dd3b86f
commit 1b534ebeb7
2 changed files with 72 additions and 58 deletions

View file

@ -691,35 +691,44 @@ impl Routine {
// adjust the below for those that are work in progress or that are implemented
// - This will allow other functions to validate that it is implemented
// WORK IN PROGRESS VECTOR - Vec<$RoutineAttr>
// // WORK IN PROGRESS VECTOR - Vec<$RoutineAttr>
let wip_attr:Vec<RoutineAttr> = vec![
RoutineAttr::DelayedStart,
RoutineAttr::ScheduledStart(chrono::offset::Local::now()),
RoutineAttr::LoopDuration(Duration::from_secs(1)),
RoutineAttr::LoopInfinitely, // Note : There's no added implementation for this
RoutineAttr::RunOnce,
RoutineAttr::MaxTimeThreshold(chrono::offset::Local::now()),
RoutineAttr::MaxIterations(1),
// let wip_attr:Vec<RoutineAttr> = vec![
// RoutineAttr::DelayedStart,
// RoutineAttr::ScheduledStart(chrono::offset::Local::now()),
// RoutineAttr::LoopDuration(Duration::from_secs(1)),
// RoutineAttr::LoopInfinitely, // Note : There's no added implementation for this
// RoutineAttr::RunOnce,
// RoutineAttr::MaxTimeThreshold(chrono::offset::Local::now()),
// RoutineAttr::MaxIterations(1),
];
// ];
let implemented_attr:Vec<RoutineAttr> = vec![
];
// let implemented_attr:Vec<RoutineAttr> = vec![
// ];
// [x] 2. Built in Logic will check these vectors, and return if Not Implemented
let mut unimplemented = routine_attr.iter()
.filter(|x| {
let inx = x;
wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|| implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
}
);
// let mut unimplemented = routine_attr.iter()
// .filter(|x| {
// let inx = x;
// wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
// && implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
// }
// );
if unimplemented.next().is_some() {
for given_routine in routine_attr {
if !matches!(given_routine,RoutineAttr::DelayedStart)
&& !matches!(given_routine,RoutineAttr::ScheduledStart(_))
&& !matches!(given_routine,RoutineAttr::LoopDuration(_))
&& !matches!(given_routine,RoutineAttr::LoopInfinitely)
&& !matches!(given_routine,RoutineAttr::RunOnce)
&& !matches!(given_routine,RoutineAttr::MaxTimeThreshold(_))
&& !matches!(given_routine,RoutineAttr::MaxIterations(_))
{
botlog::trace(
"[ERROR][Routine Feature NOT IMPLEMENTED]",
Some("Routine > Validate_attr()".to_string()),
@ -731,6 +740,23 @@ impl Routine {
return Err("NOT IMPLEMENTED".to_string());
}
};
// if unimplemented.next().is_some() {
// botlog::trace(
// "[ERROR][Routine Feature NOT IMPLEMENTED]",
// Some("Routine > Validate_attr()".to_string()),
// None,
// );
// Log::flush();
// return Err("NOT IMPLEMENTED".to_string());
// }
@ -772,15 +798,15 @@ impl Routine {
// [x] 4. If all other failure checks above works, ensure one more time that the attribute is implemented
// - If not, routine NOT IMPLEMENTED error
if routine_attr.iter()
.filter(|x| {
let inx = x;
wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|| implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
})
.next()
.is_none()
{
// if routine_attr.iter()
// .filter(|x| {
// let inx = x;
// wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
// || implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
// })
// .next()
// .is_none()
// {
botlog::trace(
"[ERROR][Routine Feature NOT IMPLEMENTED]",
@ -792,20 +818,6 @@ impl Routine {
Ok("Implemented & Validated".to_string())
} else {
botlog::trace(
"[ERROR][Routine Feature NOT IMPLEMENTED]",
Some("Routine > Validate_attr()".to_string()),
None,
);
Log::flush();
Err("NOT IMPLEMENTED".to_string())
}
}

View file

@ -142,7 +142,9 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
let module = params.get_module().await;
let channel = params.get_channel().await;
let routine_attr = vec![
RoutineAttr::RunOnce
// RoutineAttr::RunOnce
RoutineAttr::MaxIterations(5),
RoutineAttr::LoopDuration(Duration::from_secs(1))
];
// let exec_body = actions_util::asyncbox(rtestbody);
let exec_body = actions_util::asyncbox(innertester); // <-- 03.27 - when below is uncommented, this is throwing an issue