Refactor participation metrics in TrainingStatsView to use total participant counts instead of member participation estimates. Update methods for calculating average participation across different time periods to enhance accuracy and maintainability.
This commit is contained in:
@@ -165,8 +165,8 @@ export default {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const trainingsThisMonth = this.getTrainingsInPeriod(currentYear, currentMonth, currentYear, currentMonth);
|
||||
if (trainingsThisMonth === 0) return 0;
|
||||
const total = this.activeMembers.reduce((sum, member) => sum + this.getMemberParticipationInPeriod(member, currentYear, currentMonth, currentYear, currentMonth), 0);
|
||||
return total / trainingsThisMonth;
|
||||
const totalParticipants = this.getTotalParticipantsInPeriod(currentYear, currentMonth, currentYear, currentMonth);
|
||||
return totalParticipants / trainingsThisMonth;
|
||||
},
|
||||
|
||||
averageParticipationLastMonth() {
|
||||
@@ -175,8 +175,8 @@ export default {
|
||||
const actualMonth = lastMonth < 0 ? 11 : lastMonth;
|
||||
const trainingsLastMonth = this.getTrainingsInPeriod(year, actualMonth, year, actualMonth);
|
||||
if (trainingsLastMonth === 0) return 0;
|
||||
const total = this.activeMembers.reduce((sum, member) => sum + this.getMemberParticipationInPeriod(member, year, actualMonth, year, actualMonth), 0);
|
||||
return total / trainingsLastMonth;
|
||||
const totalParticipants = this.getTotalParticipantsInPeriod(year, actualMonth, year, actualMonth);
|
||||
return totalParticipants / trainingsLastMonth;
|
||||
},
|
||||
|
||||
averageParticipationQuarter() {
|
||||
@@ -185,8 +185,8 @@ export default {
|
||||
const quarterEndMonth = quarterStartMonth + 2;
|
||||
const trainingsQuarter = this.getTrainingsInPeriod(now.getFullYear(), quarterStartMonth, now.getFullYear(), quarterEndMonth);
|
||||
if (trainingsQuarter === 0) return 0;
|
||||
const total = this.activeMembers.reduce((sum, member) => sum + this.getMemberParticipationInPeriod(member, now.getFullYear(), quarterStartMonth, now.getFullYear(), quarterEndMonth), 0);
|
||||
return total / trainingsQuarter;
|
||||
const totalParticipants = this.getTotalParticipantsInPeriod(now.getFullYear(), quarterStartMonth, now.getFullYear(), quarterEndMonth);
|
||||
return totalParticipants / trainingsQuarter;
|
||||
},
|
||||
|
||||
averageParticipationHalfYear() {
|
||||
@@ -195,16 +195,16 @@ export default {
|
||||
const halfYearEndMonth = now.getMonth() < 6 ? 5 : 11;
|
||||
const trainingsHalfYear = this.getTrainingsInPeriod(now.getFullYear(), halfYearStartMonth, now.getFullYear(), halfYearEndMonth);
|
||||
if (trainingsHalfYear === 0) return 0;
|
||||
const total = this.activeMembers.reduce((sum, member) => sum + this.getMemberParticipationInPeriod(member, now.getFullYear(), halfYearStartMonth, now.getFullYear(), halfYearEndMonth), 0);
|
||||
return total / trainingsHalfYear;
|
||||
const totalParticipants = this.getTotalParticipantsInPeriod(now.getFullYear(), halfYearStartMonth, now.getFullYear(), halfYearEndMonth);
|
||||
return totalParticipants / trainingsHalfYear;
|
||||
},
|
||||
|
||||
averageParticipationYear() {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const trainingsYear = this.getTrainingsInPeriod(currentYear, 0, currentYear, 11);
|
||||
if (trainingsYear === 0) return 0;
|
||||
const total = this.activeMembers.reduce((sum, member) => sum + this.getMemberParticipationInPeriod(member, currentYear, 0, currentYear, 11), 0);
|
||||
return total / trainingsYear;
|
||||
const totalParticipants = this.getTotalParticipantsInPeriod(currentYear, 0, currentYear, 11);
|
||||
return totalParticipants / trainingsYear;
|
||||
},
|
||||
|
||||
sortedMembers() {
|
||||
@@ -300,17 +300,19 @@ export default {
|
||||
}).length;
|
||||
},
|
||||
|
||||
getMemberParticipationInPeriod(member, startYear, startMonth, endYear, endMonth) {
|
||||
// Vereinfachte Berechnung basierend auf verfügbaren Daten
|
||||
// Da wir keine detaillierten Teilnahmedaten haben, verwenden wir eine Schätzung
|
||||
// basierend auf den vorhandenen participation12Months und participation3Months
|
||||
|
||||
const totalTrainings = this.getTrainingsInPeriod(startYear, startMonth, endYear, endMonth);
|
||||
if (totalTrainings === 0) return 0;
|
||||
|
||||
// Schätzung basierend auf 12-Monats-Durchschnitt
|
||||
const avgParticipationRate = member.participation12Months / this.trainingsCount12Months;
|
||||
return Math.round(totalTrainings * avgParticipationRate);
|
||||
getTotalParticipantsInPeriod(startYear, startMonth, endYear, endMonth) {
|
||||
// Summiere die Teilnehmerzahlen aller Trainingstage im Zeitraum
|
||||
return this.trainingDays.filter(day => {
|
||||
const dayDate = new Date(day.date);
|
||||
const dayYear = dayDate.getFullYear();
|
||||
const dayMonth = dayDate.getMonth();
|
||||
|
||||
if (dayYear < startYear || dayYear > endYear) return false;
|
||||
if (dayYear === startYear && dayMonth < startMonth) return false;
|
||||
if (dayYear === endYear && dayMonth > endMonth) return false;
|
||||
|
||||
return true;
|
||||
}).reduce((sum, day) => sum + (day.participantCount || 0), 0);
|
||||
},
|
||||
|
||||
toggleTrainingDays() {
|
||||
|
||||
Reference in New Issue
Block a user