Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,15 @@
)
}

pub async fn invalidate_course_schedules(&self) -> Result {
self
.database
.collection::<Course>(Self::COURSE_COLLECTION)
.update_many(doc! {}, doc! {"$set": {"schedule": null}}, None)
.await?;
Ok(())
}

Check warning on line 1149 in crates/db/src/db.rs

View check run for this annotation

Codecov / codecov/patch

crates/db/src/db.rs#L1142-L1149

Added lines #L1142 - L1149 were not covered by tests

#[cfg(test)]
async fn instructors(&self) -> Result<Vec<Instructor>> {
Ok(
Expand Down
5 changes: 5 additions & 0 deletions crates/db/src/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
}
}

if self.options.invalidate_schedules {
info!("Invalidating course schedules...");
self.db.invalidate_course_schedules().await?;

Check warning on line 137 in crates/db/src/initializer.rs

View check run for this annotation

Codecov / codecov/patch

crates/db/src/initializer.rs#L136-L137

Added lines #L136 - L137 were not covered by tests
}

for seed in seeds {
match seed {
Seed::Courses((path, courses)) if !self.options.skip_courses => {
Expand Down
1 change: 0 additions & 1 deletion crates/model/src/course.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl Course {
logical_corequisites: other
.logical_corequisites
.or(self.logical_corequisites),
schedule: Some(other.schedule.combine_opt(self.schedule)),
..other
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/model/src/initialize_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pub struct InitializeOptions {
pub skip_courses: bool,
pub skip_reviews: bool,
pub source: PathBuf,
pub invalidate_schedules: bool,
}
1 change: 0 additions & 1 deletion crates/model/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {
bson::{doc, Bson, DateTime},
combine::Combine,
derivative::Derivative,
serde::{Deserialize, Serialize},
std::{
Expand Down
7 changes: 7 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
skip_courses: bool,
#[clap(long, default_value = "false", help = "Skip review seeding")]
skip_reviews: bool,
#[clap(
long,
default_value = "false",
help = "Overwrite course schedules instead of combining"
)]
invalidate_schedules: bool,

Check warning on line 26 in src/server.rs

View check run for this annotation

Codecov / codecov/patch

src/server.rs#L26

Added line #L26 was not covered by tests
}

#[derive(Debug)]
Expand Down Expand Up @@ -65,6 +71,7 @@
multithreaded: self.multithreaded,
skip_courses: self.skip_courses,
skip_reviews: self.skip_reviews,
invalidate_schedules: self.invalidate_schedules,

Check warning on line 74 in src/server.rs

View check run for this annotation

Codecov / codecov/patch

src/server.rs#L74

Added line #L74 was not covered by tests
source,
})
.await
Expand Down
Loading