From 35a49ee5d0d5e490d8ee95e5c24895aba380d3d4 Mon Sep 17 00:00:00 2001 From: PineND Date: Wed, 30 Oct 2024 16:06:12 -0700 Subject: [PATCH] minor type casting fixes --- apps/backend/src/modules/rating/formatter.ts | 9 +++++---- packages/common/src/models/rating.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/modules/rating/formatter.ts b/apps/backend/src/modules/rating/formatter.ts index 1bf257fcf..c3320eea4 100644 --- a/apps/backend/src/modules/rating/formatter.ts +++ b/apps/backend/src/modules/rating/formatter.ts @@ -3,14 +3,15 @@ import { Rating, AggregatedRatings, Metric, - Category -} from './typedefs/rating'; + Category, + Semester +} from '../../generated-types/graphql'; // mongo -> graphql (models -> typedefs) export const formatUserRating = (rating: RatingType): Rating => ({ subject: rating.subject, courseNumber: rating.courseNumber, - semester: rating.semester, + semester: rating.semester as Semester, year: rating.year, class: rating.class, @@ -22,7 +23,7 @@ export const formatUserRating = (rating: RatingType): Rating => ({ // does mongo always return an array? single return val vs multiple val export const formatUserRatings = (ratings: any[]): Rating[] => { - return ratings.map(formatUserRatings); + return ratings.map(formatUserRating); }; // grandparent group by class -> done diff --git a/packages/common/src/models/rating.ts b/packages/common/src/models/rating.ts index 17c766070..8ba571c37 100644 --- a/packages/common/src/models/rating.ts +++ b/packages/common/src/models/rating.ts @@ -28,7 +28,7 @@ const ratingSchema = new Schema({ required: true, }, year: { - type: String, + type: Number, required: true, }, class: {