From d6b883e642ef9e2666a4778b3c82fd8b6ddcb60a Mon Sep 17 00:00:00 2001 From: Eddy Chen <89349085+ecxyzzy@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:56:32 -0700 Subject: [PATCH] fix: :bug: make sure average GPA field is not NaN (#85) --- apps/api/v1/rest/grades/src/lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/v1/rest/grades/src/lib.ts b/apps/api/v1/rest/grades/src/lib.ts index 76a7ed50..727bdbae 100644 --- a/apps/api/v1/rest/grades/src/lib.ts +++ b/apps/api/v1/rest/grades/src/lib.ts @@ -92,7 +92,7 @@ export function aggregateGrades(grades: GradesRaw): GradesAggregate { ).map((key) => [key, grades.reduce((a, { [key]: b }) => a + b, 0)]), ) as Omit), averageGPA: - grades.reduce((a, { averageGPA: b }) => a + b, 0) / grades.filter(isNotPNPOnly).length, + grades.reduce((a, { averageGPA: b }) => a + b, 0) / grades.filter(isNotPNPOnly).length || 0, }, }; }