forked from Anri/cal8tor
wip check timetable consistency
This commit is contained in:
parent
d726a7f778
commit
818c8eb40f
1 changed files with 17 additions and 2 deletions
19
src/main.rs
19
src/main.rs
|
@ -31,7 +31,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
for time in raw_schedules.select(&sel_th) {
|
for time in raw_schedules.select(&sel_th) {
|
||||||
schedules.push(time.inner_html());
|
schedules.push(time.inner_html());
|
||||||
}
|
}
|
||||||
println!("{:#?}", schedules);
|
|
||||||
|
|
||||||
// Find the timetable values
|
// Find the timetable values
|
||||||
let raw_timetable_values = raw_timetable.select(&sel_tbody).next().unwrap();
|
let raw_timetable_values = raw_timetable.select(&sel_tbody).next().unwrap();
|
||||||
|
@ -58,9 +57,25 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
courses: courses_vec,
|
courses: courses_vec,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
println!("{:#?}", timetable);
|
|
||||||
|
|
||||||
// TODO: Make fn who chacke if timetable is bell built (time consistency)
|
// 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if the timetable is well built
|
||||||
|
fn check_timetable_consistency(schedules: &Vec<String>, timetable: &Vec<models::Day>) -> 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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue