fix: update average calcul
This commit is contained in:
parent
11ffda9995
commit
71d0a35478
1 changed files with 5 additions and 4 deletions
|
|
@ -3,11 +3,12 @@ import { DateTime } from 'luxon'
|
|||
|
||||
export class GradeService {
|
||||
private calculateAverage(colles: Colle[]) {
|
||||
const total = colles
|
||||
const grades = colles
|
||||
.map((colle) => parseFloat(colle.grade?.toString()))
|
||||
.filter(Boolean)
|
||||
.reduce((sum, grade) => sum + grade, 0)
|
||||
return (total / colles.length).toFixed(2)
|
||||
.filter((g) => !isNaN(g) && g !== undefined)
|
||||
if (grades.length === 0) return '0.00'
|
||||
const total = grades.reduce((sum, g) => sum + g, 0)
|
||||
return (total / grades.length).toFixed(2)
|
||||
}
|
||||
|
||||
private calculateSubjectAverage(colles: Colle[], subject: string) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue