forked from Anri/cal8tor
use tuple instead of hashmaps
This commit is contained in:
parent
6ecf7551a2
commit
37a4e61ce5
2 changed files with 10 additions and 5 deletions
|
@ -3,7 +3,12 @@ use ics::{
|
|||
Event, ICalendar,
|
||||
};
|
||||
|
||||
type T = Vec<crate::timetable::models::Day>;
|
||||
type T = (
|
||||
// Schedules
|
||||
Vec<String>,
|
||||
// Timetable per days with the semester as the key
|
||||
(usize, Vec<crate::timetable::models::Day>),
|
||||
);
|
||||
type D = std::collections::HashMap<
|
||||
usize,
|
||||
Vec<(chrono::DateTime<chrono::Utc>, chrono::DateTime<chrono::Utc>)>,
|
||||
|
@ -36,5 +41,7 @@ pub fn export(_timetable: T, _dates: D) -> ICalendar<'static> {
|
|||
|
||||
calendar.save_file("target/debug2.ics").unwrap();
|
||||
|
||||
println!("{:#?} - {:#?}", _timetable, _dates);
|
||||
|
||||
calendar
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use scraper::{Html, Selector};
|
||||
|
||||
pub mod models;
|
||||
|
@ -9,7 +7,7 @@ pub async fn timetable(
|
|||
year: i8,
|
||||
semester: i8,
|
||||
letter: Option<char>,
|
||||
) -> HashMap<usize, Vec<models::Day>> {
|
||||
) -> (Vec<String>, (usize, Vec<models::Day>)) {
|
||||
let document = get_webpage(year, semester, letter)
|
||||
.await
|
||||
.expect("Can't reach timetable website.");
|
||||
|
@ -100,7 +98,7 @@ pub async fn timetable(
|
|||
panic!("Error when building the timetable.");
|
||||
}
|
||||
|
||||
HashMap::from([(semester as usize, timetable)])
|
||||
(schedules, (semester as usize, timetable))
|
||||
}
|
||||
|
||||
/// Get timetable webpage
|
||||
|
|
Loading…
Reference in a new issue