fixed routine attr validation logic
This commit is contained in:
parent
c27dd3b86f
commit
1b534ebeb7
2 changed files with 72 additions and 58 deletions
|
@ -691,45 +691,71 @@ impl Routine {
|
||||||
// adjust the below for those that are work in progress or that are implemented
|
// 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
|
// - 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![
|
// let wip_attr:Vec<RoutineAttr> = vec![
|
||||||
RoutineAttr::DelayedStart,
|
// RoutineAttr::DelayedStart,
|
||||||
RoutineAttr::ScheduledStart(chrono::offset::Local::now()),
|
// RoutineAttr::ScheduledStart(chrono::offset::Local::now()),
|
||||||
RoutineAttr::LoopDuration(Duration::from_secs(1)),
|
// RoutineAttr::LoopDuration(Duration::from_secs(1)),
|
||||||
RoutineAttr::LoopInfinitely, // Note : There's no added implementation for this
|
// RoutineAttr::LoopInfinitely, // Note : There's no added implementation for this
|
||||||
RoutineAttr::RunOnce,
|
// RoutineAttr::RunOnce,
|
||||||
RoutineAttr::MaxTimeThreshold(chrono::offset::Local::now()),
|
// RoutineAttr::MaxTimeThreshold(chrono::offset::Local::now()),
|
||||||
RoutineAttr::MaxIterations(1),
|
// 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
|
// [x] 2. Built in Logic will check these vectors, and return if Not Implemented
|
||||||
|
|
||||||
let mut unimplemented = routine_attr.iter()
|
// let mut unimplemented = routine_attr.iter()
|
||||||
.filter(|x| {
|
// .filter(|x| {
|
||||||
let inx = x;
|
// let inx = x;
|
||||||
wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|
// 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()
|
// && implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
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()),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
|
Log::flush();
|
||||||
|
|
||||||
|
return Err("NOT IMPLEMENTED".to_string());
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if unimplemented.next().is_some() {
|
};
|
||||||
|
|
||||||
botlog::trace(
|
|
||||||
"[ERROR][Routine Feature NOT IMPLEMENTED]",
|
|
||||||
Some("Routine > Validate_attr()".to_string()),
|
// if unimplemented.next().is_some() {
|
||||||
None,
|
|
||||||
);
|
// botlog::trace(
|
||||||
|
// "[ERROR][Routine Feature NOT IMPLEMENTED]",
|
||||||
|
// Some("Routine > Validate_attr()".to_string()),
|
||||||
|
// None,
|
||||||
|
// );
|
||||||
|
|
||||||
Log::flush();
|
// Log::flush();
|
||||||
|
|
||||||
return Err("NOT IMPLEMENTED".to_string());
|
// return Err("NOT IMPLEMENTED".to_string());
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -772,40 +798,26 @@ impl Routine {
|
||||||
// [x] 4. If all other failure checks above works, ensure one more time that the attribute is implemented
|
// [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 not, routine NOT IMPLEMENTED error
|
||||||
|
|
||||||
if routine_attr.iter()
|
// if routine_attr.iter()
|
||||||
.filter(|x| {
|
// .filter(|x| {
|
||||||
let inx = x;
|
// let inx = x;
|
||||||
wip_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|
// 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()
|
// || implemented_attr.iter().filter(|y| matches!(y,i if i == inx)).next().is_none()
|
||||||
})
|
// })
|
||||||
.next()
|
// .next()
|
||||||
.is_none()
|
// .is_none()
|
||||||
{
|
// {
|
||||||
|
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
"[ERROR][Routine Feature NOT IMPLEMENTED]",
|
"[ERROR][Routine Feature NOT IMPLEMENTED]",
|
||||||
Some("Routine > Validate_attr()".to_string()),
|
Some("Routine > Validate_attr()".to_string()),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
|
||||||
Ok("Implemented & Validated".to_string())
|
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())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,9 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
||||||
let module = params.get_module().await;
|
let module = params.get_module().await;
|
||||||
let channel = params.get_channel().await;
|
let channel = params.get_channel().await;
|
||||||
let routine_attr = vec![
|
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(rtestbody);
|
||||||
let exec_body = actions_util::asyncbox(innertester); // <-- 03.27 - when below is uncommented, this is throwing an issue
|
let exec_body = actions_util::asyncbox(innertester); // <-- 03.27 - when below is uncommented, this is throwing an issue
|
||||||
|
|
Loading…
Reference in a new issue