Skip to content

Commit

Permalink
fix endpoint errors for new api
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Feb 24, 2025
1 parent eaedc36 commit 4d13730
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 38 deletions.
28 changes: 12 additions & 16 deletions apps/backend/src/modules/course/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,24 @@ export const getCourses = async () => {
{
$match: {
printInCatalog: true,
"status.code": "ACTIVE",
"catalogNumber.prefix": "",
},
},
{
$sort: {
"classSubjectArea.code": 1,
"catalogNumber.formatted": 1,
subject: 1,
number: 1,
fromDate: -1,
},
},
{
$group: {
_id: "$displayName",
document: { $first: "$$ROOT" },
},
},
{
$replaceRoot: { newRoot: "$document" },
},
// {
// $group: {
// _id: "$displayName",
// document: { $first: "$$ROOT" },
// },
// },
// {
// $replaceRoot: { newRoot: "$document" },
// },
]);

// /* Map grades to course keys for easy lookup */
Expand Down Expand Up @@ -130,9 +128,7 @@ export const getCourses = async () => {

return courses.map((c) => ({
...formatCourse(c),
gradeDistribution: {
average: null,
},
gradeDistribution: null,
})) as (Exclude<IntermediateCourse, "gradeDistribution"> & {
gradeDistribution: CourseModule.Course["gradeDistribution"];
})[];
Expand Down
15 changes: 7 additions & 8 deletions apps/backend/src/modules/course/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const resolvers: CourseModule.Resolvers = {
},
},

// @ts-expect-error - Not sure how to type properly
// Session: {
// R: "1",
// S: "12W",
Expand All @@ -123,13 +122,13 @@ const resolvers: CourseModule.Resolvers = {
// F: "3W2",
// },

CourseFinalExam: {
D: "To be decided by the instructor when the class is offered",
N: "No final exam",
A: "Alternative method of final assessment",
C: "Common Final Exam",
Y: "Written final exam conducted during the scheduled final exam period",
},
// CourseFinalExam: {
// D: "To be decided by the instructor when the class is offered",
// N: "No final exam",
// A: "Alternative method of final assessment",
// C: "Common Final Exam",
// Y: "Written final exam conducted during the scheduled final exam period",
// },

// ClassGradingBasis: {
// ESU: "Elective Satisfactory/Unsat",
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/src/modules/enrollment/controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NewEnrollmentHistoryModel } from "@repo/common";

import { Semester } from "../../generated-types/graphql";
import { formatEnrollment } from "./formatter";

export const getEnrollment = async (
year: number,
semester: string,
semester: Semester,
sessionId: string | null,
subject: string,
courseNumber: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { gql } from "graphql-tag";
export default gql`
type GradeDistribution @cacheControl(maxAge: 1) {
average: Float
distribution: [Grade!]!
distribution: [Grade!]
}
type Grade @cacheControl(maxAge: 1) {
Expand Down
5 changes: 3 additions & 2 deletions apps/backend/src/modules/term/controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TermModel } from "@repo/common";

import { AcademicCareerCode, Semester } from "../../generated-types/graphql";
import { formatTerm } from "./formatter";

// database schema fields to select on queries.
Expand Down Expand Up @@ -27,8 +28,8 @@ export const getTerms = async () => {

export const getTerm = async (
year: number,
semester: string,
academicCareerCode: string = "UGRD"
semester: Semester,
academicCareerCode: AcademicCareerCode = "UGRD"
) => {
const term = await TermModel.findOne({
name: `${year} ${semester}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/modules/term/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const resolvers: TermModule.Resolvers = {
Query: {
terms: () => getTerms(),

term: (_, { id, academicCareerCode }) => getTerm(id, academicCareerCode),
term: (_, { year, semester }) => getTerm(year, semester),
},
};

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/modules/term/typedefs/term.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const typedef = gql`
"""
Query for a term.
"""
term(id: TermIdentifier!, academicCareerCode: AcademicCareerCode!): Term
term(year: Int!, semester: Semester!): Term
}
`;

Expand Down
14 changes: 10 additions & 4 deletions apps/frontend/src/lib/api/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export enum FinalExam {
Undecided = "D",
}

export enum ExamType {
Final = "FIN",
Midterm = "MID",
Alternate = "ALT",
MakeUp = "MAK",
}

export interface IInstructor {
familyName: string;
givenName: string;
Expand All @@ -119,7 +126,7 @@ export interface IInstructor {
export interface IExam {
date: string;
location: string;
final: boolean;
type: ExamType;
startTime: string;
endTime: string;
}
Expand Down Expand Up @@ -279,7 +286,7 @@ export const READ_CLASS = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand All @@ -290,7 +297,6 @@ export const READ_CLASS = gql`
sectionId
component
online
open
startDate
endDate
enrollment {
Expand Down Expand Up @@ -319,7 +325,7 @@ export const READ_CLASS = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand Down
8 changes: 4 additions & 4 deletions apps/frontend/src/lib/api/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const READ_SCHEDULE = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand Down Expand Up @@ -145,7 +145,7 @@ export const READ_SCHEDULE = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand Down Expand Up @@ -215,7 +215,7 @@ export const UPDATE_SCHEDULE = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand Down Expand Up @@ -251,7 +251,7 @@ export const UPDATE_SCHEDULE = gql`
}
exams {
date
final
type
location
startTime
endTime
Expand Down

0 comments on commit 4d13730

Please sign in to comment.