forked from Anri/cal8tor
use random uid
This commit is contained in:
parent
4ab23caf00
commit
c62bcab28f
3 changed files with 25 additions and 1 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -66,6 +66,7 @@ dependencies = [
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"scraper",
|
"scraper",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1438,6 +1439,16 @@ version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
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]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
|
|
|
@ -12,3 +12,10 @@ scraper = "0.13.0"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
ics = "0.5"
|
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
|
||||||
|
]
|
||||||
|
|
|
@ -8,22 +8,28 @@ pub fn export(courses: Vec<crate::timetable::models::Course>, filename: &str) {
|
||||||
|
|
||||||
// Create events which contains the information regarding the course
|
// Create events which contains the information regarding the course
|
||||||
for course in courses {
|
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
|
// Public event
|
||||||
event.push(Class::public());
|
event.push(Class::public());
|
||||||
|
|
||||||
// Consume actual time
|
// Consume actual time
|
||||||
event.push(Transp::opaque());
|
event.push(Transp::opaque());
|
||||||
|
|
||||||
// Professor's name
|
// Professor's name
|
||||||
if course.professor.is_some() {
|
if course.professor.is_some() {
|
||||||
event.push(Description::new(course.professor.unwrap()));
|
event.push(Description::new(course.professor.unwrap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start time of the course
|
// Start time of the course
|
||||||
event.push(DtStart::new(dt_ical(course.dtstart.unwrap())));
|
event.push(DtStart::new(dt_ical(course.dtstart.unwrap())));
|
||||||
|
|
||||||
// End time of the course
|
// End time of the course
|
||||||
event.push(DtEnd::new(dt_ical(course.dtend.unwrap())));
|
event.push(DtEnd::new(dt_ical(course.dtend.unwrap())));
|
||||||
|
|
||||||
// Room location
|
// Room location
|
||||||
event.push(Location::new(course.room));
|
event.push(Location::new(course.room));
|
||||||
|
|
||||||
// Course's name
|
// Course's name
|
||||||
event.push(Summary::new(course.name));
|
event.push(Summary::new(course.name));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue