From c2ea539b44a84339c21cd76c971703e193207016 Mon Sep 17 00:00:00 2001 From: Eddy Chen <89349085+ecxyzzy@users.noreply.github.com> Date: Wed, 23 Aug 2023 09:58:15 -0700 Subject: [PATCH] fix: :bug: make sure average GPA field is not NaN --- 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, }, }; }