use random uid

This commit is contained in:
Mylloon 2022-08-16 14:22:04 +02:00
parent 4ab23caf00
commit c62bcab28f
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 25 additions and 1 deletions

11
Cargo.lock generated
View file

@ -66,6 +66,7 @@ dependencies = [
"reqwest",
"scraper",
"tokio",
"uuid",
]
[[package]]
@ -1438,6 +1439,16 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "uuid"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f"
dependencies = [
"getrandom 0.2.7",
"rand 0.8.5",
]
[[package]]
name = "vcpkg"
version = "0.2.15"

View file

@ -12,3 +12,10 @@ scraper = "0.13.0"
regex = "1"
chrono = "0.4"
ics = "0.5"
[dependencies.uuid]
version = "1.1.2"
features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
]

View file

@ -8,22 +8,28 @@ pub fn export(courses: Vec<crate::timetable::models::Course>, filename: &str) {
// Create events which contains the information regarding the course
for course in courses {
let mut event = Event::new("uid", "dtstamp");
let mut event = Event::new(uuid::Uuid::new_v4().to_string(), dt_ical(chrono::Utc::now()));
// Public event
event.push(Class::public());
// Consume actual time
event.push(Transp::opaque());
// Professor's name
if course.professor.is_some() {
event.push(Description::new(course.professor.unwrap()));
}
// Start time of the course
event.push(DtStart::new(dt_ical(course.dtstart.unwrap())));
// End time of the course
event.push(DtEnd::new(dt_ical(course.dtend.unwrap())));
// Room location
event.push(Location::new(course.room));
// Course's name
event.push(Summary::new(course.name));