From 1684302bc0c14ec79c013890ca9da84c27b30536 Mon Sep 17 00:00:00 2001 From: evermake Date: Sun, 7 Apr 2024 20:55:21 +0300 Subject: [PATCH] fix: filter semesters summary properly (again) --- backend/src/domain/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/domain/index.ts b/backend/src/domain/index.ts index 2b34479..ebcf562 100644 --- a/backend/src/domain/index.ts +++ b/backend/src/domain/index.ts @@ -144,10 +144,22 @@ export class Domain { const hours = allSportHours.find(h => h.id_sem === id) const fitTest = allFitnessTests.find(t => t.semester === name) + let hasSomeHours = hours != null && ( + hours.hours_not_self !== 0 + || hours.hours_self_not_debt !== 0 + || hours.hours_self_debt !== 0 + || hours.debt !== 0 + ) + if (!hasSomeHours && id === sportHours.ongoing_semester.id_sem) { + hasSomeHours = true + } + return { title: name, - hoursTotal: hours - ? (hours.hours_not_self + hours.hours_self_debt + hours.hours_self_not_debt) + hoursTotal: hasSomeHours + ? hours + ? (hours.hours_not_self + hours.hours_self_debt + hours.hours_self_not_debt) + : 0 : undefined, fitnessTest: fitTest ? {