Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.0.5 #130

Merged
merged 23 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Add handlers for in progress compute
before degree-status compute, we check compute_in_progress flag and change courses statuses if needed.
  • Loading branch information
liadaram1 committed Mar 20, 2022
commit 6b296a31340f87f911f4becfabd367ad374ea032
8 changes: 8 additions & 0 deletions packages/server/src/api/students.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,18 @@ pub async fn compute_degree_status(
.malag_list
.clone(); // The collection malags contain one item with the list of all malags

let mut course_list = Vec::new();
if user.settings.compute_in_progress {
course_list = user_details.degree_status.set_in_progress_to_complete();
}

user_details
.degree_status
.compute(catalog, course::vec_to_map(vec_courses), malag_courses);

if user.settings.compute_in_progress {
user_details.degree_status.set_to_in_progress(course_list);
}
let user_id = user.sub.clone();
let document = doc! {"$set" : user.clone().into_document()};
db::services::find_and_update_user(&user_id, document, &client).await?;
Expand Down
28 changes: 28 additions & 0 deletions packages/server/src/core/degree_status/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,34 @@ impl DegreeStatus {
}
None
}

// This function sets the state for all courses where their state is "in progress" to "complete"
// and returns a list of all courses which were changed, (CourseId, Semester) is a key for each courseStatus.
pub fn set_in_progress_to_complete(&mut self) -> Vec<(CourseId, Option<String>)> {
let mut changed_course_statuses = Vec::new();
for course_status in self.course_statuses.iter_mut() {
if course_status.state == Some(CourseState::InProgress) {
changed_course_statuses.push((
course_status.course.id.clone(),
course_status.semester.clone(),
));
course_status.state = Some(CourseState::InProgress);
}
}
changed_course_statuses
}

// This function gets a list of courses and sets their state to "in progress"
pub fn set_to_in_progress(&mut self, course_list: Vec<(CourseId, Option<String>)>) {
for course_status in self.course_statuses.iter_mut() {
if course_list.contains(&(
course_status.course.id.clone(),
course_status.semester.clone(),
)) {
course_status.state = Some(CourseState::Complete);
}
}
}
}

pub struct DegreeStatusHandler<'a> {
Expand Down