From 818c8eb40f9bb8737445c3888a90dbddb432a398 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 13 Aug 2022 17:27:35 +0200 Subject: [PATCH] wip check timetable consistency --- src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index ad1cfa7..b15c720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,6 @@ async fn main() -> Result<(), Box> { for time in raw_schedules.select(&sel_th) { schedules.push(time.inner_html()); } - println!("{:#?}", schedules); // Find the timetable values let raw_timetable_values = raw_timetable.select(&sel_tbody).next().unwrap(); @@ -58,9 +57,25 @@ async fn main() -> Result<(), Box> { courses: courses_vec, }) } - println!("{:#?}", timetable); // TODO: Make fn who chacke if timetable is bell built (time consistency) + if !check_timetable_consistency(&schedules, &timetable) { + panic!("Error when building the timetable."); + } Ok(()) } + +/// Check if the timetable is well built +fn check_timetable_consistency(schedules: &Vec, timetable: &Vec) -> bool { + // No work during week-end + if timetable.len() == 5 { + // TODO: Check if schedules.len() is coherent + // with the values inside the timetable + println!("{:#?}", schedules); + println!("{:#?}", timetable); + return true; + } + + false +}