Skip to content

Commit

Permalink
Parallelize Schedule Load Websoc Requests (#713)
Browse files Browse the repository at this point in the history
Co-authored-by: Aponia <[email protected]>
  • Loading branch information
2 people authored and MinhxNguyen7 committed Oct 1, 2023
1 parent 8286e60 commit f70aa8d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions apps/antalmanac/src/stores/Schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,14 @@ 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 sectionCodes = Array.from(courseSet);
// Code from ImportStudyList
const courseInfo = getCourseInfo(
await queryWebsoc({
term: term,
sectionCodes: sectionCodes.join(','),
})
);

const websocRequests = Object.entries(courseDict).map(async ([term, courseSet]) => {
const sectionCodes = Array.from(courseSet).join(',');
const courseInfo = getCourseInfo(await queryWebsoc({ term, sectionCodes }));
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) {
Expand Down

0 comments on commit f70aa8d

Please sign in to comment.