Skip to content

Commit

Permalink
minor type casting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PineND committed Oct 30, 2024
1 parent 9aa0933 commit 35a49ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions apps/backend/src/modules/rating/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/models/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ratingSchema = new Schema({
required: true,
},
year: {
type: String,
type: Number,
required: true,
},
class: {
Expand Down

0 comments on commit 35a49ee

Please sign in to comment.