From f1ba25f9f5403472adf389ade0d2599bb151ff7f Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 8 Oct 2025 14:54:57 +0200 Subject: [PATCH] Implement logic to determine the quarter with the highest training data in TrainingStatsView. Update average participation calculation to reflect the best quarter's total participants, enhancing accuracy in participation metrics. --- frontend/src/views/TrainingStatsView.vue | 36 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/frontend/src/views/TrainingStatsView.vue b/frontend/src/views/TrainingStatsView.vue index 9697f80..3d07f5c 100644 --- a/frontend/src/views/TrainingStatsView.vue +++ b/frontend/src/views/TrainingStatsView.vue @@ -180,13 +180,35 @@ export default { }, averageParticipationQuarter() { - const now = new Date(); - const quarterStartMonth = Math.floor(now.getMonth() / 3) * 3; - const quarterEndMonth = quarterStartMonth + 2; - const trainingsQuarter = this.getTrainingsInPeriod(now.getFullYear(), quarterStartMonth, now.getFullYear(), quarterEndMonth); - if (trainingsQuarter === 0) return 0; - const totalParticipants = this.getTotalParticipantsInPeriod(now.getFullYear(), quarterStartMonth, now.getFullYear(), quarterEndMonth); - return totalParticipants / trainingsQuarter; + // Finde das Quartal mit den meisten Trainingsdaten + const quarters = [ + { year: 2024, startMonth: 0, endMonth: 2, name: 'Q1 2024' }, + { year: 2024, startMonth: 3, endMonth: 5, name: 'Q2 2024' }, + { year: 2024, startMonth: 6, endMonth: 8, name: 'Q3 2024' }, + { year: 2024, startMonth: 9, endMonth: 11, name: 'Q4 2024' }, + { year: 2025, startMonth: 0, endMonth: 2, name: 'Q1 2025' }, + { year: 2025, startMonth: 3, endMonth: 5, name: 'Q2 2025' }, + { year: 2025, startMonth: 6, endMonth: 8, name: 'Q3 2025' }, + { year: 2025, startMonth: 9, endMonth: 11, name: 'Q4 2025' } + ]; + + let bestQuarter = null; + let maxTrainings = 0; + + for (const quarter of quarters) { + const trainings = this.getTrainingsInPeriod(quarter.year, quarter.startMonth, quarter.year, quarter.endMonth); + if (trainings > maxTrainings) { + maxTrainings = trainings; + bestQuarter = quarter; + } + } + + if (!bestQuarter || maxTrainings === 0) return 0; + + console.log('🔍 Bestes Quartal:', bestQuarter.name, 'mit', maxTrainings, 'Trainings'); + + const totalParticipants = this.getTotalParticipantsInPeriod(bestQuarter.year, bestQuarter.startMonth, bestQuarter.year, bestQuarter.endMonth); + return totalParticipants / maxTrainings; }, averageParticipationHalfYear() {