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

Update controller.ts #691

Merged
merged 3 commits into from
Apr 11, 2024
Merged
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
16 changes: 10 additions & 6 deletions backend/src/modules/catalog/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
.find(
{
identifiers: matchCsCourseId({ $in: Array.from(csCourseIds) }),
/*
/*
The SIS toDate is unreliable so we can only
filter by fromDate and then sort to find the
most recent course.
Expand Down Expand Up @@ -69,8 +69,8 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
if (children.includes("gradeAverage")) {
const grades = await GradeModel.find(
{
/*
No filters because an appropriately large filter
/*
No filters because an appropriately large filter
is actually significantly slower than no filter.
*/
},
Expand All @@ -81,7 +81,7 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
EnrollmentCnt: 1
}
).lean()

for (const g of grades) {
const key = `${g.CourseSubjectShortNm as string} ${g.CourseNumber as string}`
if (key in gradesMap) {
Expand Down Expand Up @@ -110,9 +110,13 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
const id = getCsCourseId(c.course as CourseType)

if (!(id in catalog)) {
throw new Error(`Class ${c.course?.subjectArea?.code} ${c.course?.catalogNumber?.formatted}`
+ ` has a course id ${id} that doesn't exist for the ${term.semester} ${term.year} term.`)
// throw new Error(`Class ${c.course?.subjectArea?.code} ${c.course?.catalogNumber?.formatted}`
// + ` has a course id ${id} that doesn't exist for the ${term.semester} ${term.year} term.`)

// TODO(production): log
continue;
}

catalog[id].classes.push(formatClass(c))
}

Expand Down
Loading