Erweitert die Trainingsstatistik-Funktionalität im TrainingStatsController, um die Anzahl der Trainings in den letzten 12 und 3 Monaten zu berechnen und zurückzugeben. Aktualisiert die Benutzeroberfläche in TrainingStatsView.vue zur Anzeige dieser neuen Daten. Ändert die Navigation in App.vue, um direkt zu den Trainingsstatistiken zu führen.

This commit is contained in:
Torsten Schulz (local)
2025-10-01 13:01:54 +02:00
parent 4ac71d967f
commit 648b608036
3 changed files with 36 additions and 8 deletions

View File

@@ -133,7 +133,7 @@ export default {
if (newVal === 'new') {
this.$router.push('/createclub');
} else if (newVal) {
this.$router.push(`/showclub/${newVal}`);
this.$router.push('/training-stats');
}
},
isAuthenticated(newVal) {
@@ -171,7 +171,7 @@ export default {
loadClub() {
this.setCurrentClub(this.currentClub);
this.$router.push(`/showclub/${this.currentClub}`);
this.$router.push('/training-stats');
},
async checkSession() {

View File

@@ -126,15 +126,15 @@ export default {
...mapGetters(['isAuthenticated', 'currentClub']),
averageParticipation12Months() {
if (this.activeMembers.length === 0) return 0;
if (this.trainingsCount12Months === 0) return 0;
const total = this.activeMembers.reduce((sum, member) => sum + member.participation12Months, 0);
return total / this.activeMembers.length;
return total / this.trainingsCount12Months;
},
averageParticipation3Months() {
if (this.activeMembers.length === 0) return 0;
if (this.trainingsCount3Months === 0) return 0;
const total = this.activeMembers.reduce((sum, member) => sum + member.participation3Months, 0);
return total / this.activeMembers.length;
return total / this.trainingsCount3Months;
},
sortedMembers() {
@@ -167,6 +167,8 @@ export default {
data() {
return {
activeMembers: [],
trainingsCount12Months: 0,
trainingsCount3Months: 0,
showDetailsModal: false,
selectedMember: {},
loading: false,
@@ -199,7 +201,9 @@ export default {
this.loading = true;
try {
const response = await apiClient.get(`/training-stats/${this.currentClub}`);
this.activeMembers = response.data;
this.activeMembers = response.data.members || [];
this.trainingsCount12Months = response.data.trainingsCount12Months || 0;
this.trainingsCount3Months = response.data.trainingsCount3Months || 0;
} catch (error) {
// Kein Alert - es ist normal, dass nicht alle Daten verfügbar sind
} finally {