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.
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user