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

Parallelize Schedule Load Websoc Requests #713

Merged
merged 3 commits into from
Oct 1, 2023
Merged
Changes from 1 commit
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: 6 additions & 3 deletions apps/antalmanac/src/stores/Schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,20 +461,23 @@ export class Schedules {

// Get the course info for each course
const courseInfoDict = new Map<string, { [sectionCode: string]: CourseInfo }>();
for (const [term, courseSet] of Object.entries(courseDict)) {

const websocRequests = Object.entries(courseDict).map(async ([term, courseSet]) => {
const sectionCodes = Array.from(courseSet);
EricPedley marked this conversation as resolved.
Show resolved Hide resolved
// Code from ImportStudyList
const courseInfo = getCourseInfo(
await queryWebsoc({
term: term,
sectionCodes: sectionCodes.join(','),
})
);
EricPedley marked this conversation as resolved.
Show resolved Hide resolved
courseInfoDict.set(term, courseInfo);
}
});

await Promise.all(websocRequests);

// Map course info to courses and transform shortened schedule to normal schedule
for (const shortCourseSchedule of saveState.schedules) {
console.log(shortCourseSchedule);
EricPedley marked this conversation as resolved.
Show resolved Hide resolved
const courses: ScheduleCourse[] = [];
for (const shortCourse of shortCourseSchedule.courses) {
const courseInfoMap = courseInfoDict.get(shortCourse.term);
Expand Down