diff --git a/client/src/components/dashboard/TrainingResponsibleStatistics.vue b/client/src/components/dashboard/TrainingResponsibleStatistics.vue index b9625a77..8d41383e 100644 --- a/client/src/components/dashboard/TrainingResponsibleStatistics.vue +++ b/client/src/components/dashboard/TrainingResponsibleStatistics.vue @@ -17,6 +17,8 @@ onMounted(async () => { statistics.value = await fetchTrainingResponsibleStatistics(props.courseSessionId); }); +const currentYear = new Date().getFullYear(); + const totalCostInCurrentYear = computed(() => { return statistics.value?.training_responsible_statistics?.cost_per_year.find( (cost) => cost?.year === new Date().getFullYear() @@ -33,9 +35,9 @@ const attendanceCountInCurrentYear = computed(() => { const attendanceCountPerChosenProfile = computed(() => { const allAttendances = - statistics.value?.training_responsible_statistics?.participants_per_year?.flatMap( - (entry) => entry?.participants ?? [] - ); + statistics.value?.training_responsible_statistics?.participants_per_year + ?.filter((entry) => entry?.year === currentYear) + ?.flatMap((entry) => entry?.participants ?? []); return allAttendances?.reduce( (acc, attendance) => { const chosenProfile = attendance?.chosen_profile || "all"; @@ -58,7 +60,7 @@ const attendanceCountPerChosenProfile = computed(() => { data-cy="dashboard.stats.trainingResponsible.cost" class="w-1/2" > - + - +