Added dynmaic loading for databank statsistics
This commit is contained in:
@@ -10,17 +10,36 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
stats: {
|
||||
totalParks: 10,
|
||||
totalCoasters: 25,
|
||||
totalVisitorsPerMonth: 500000,
|
||||
averageTicketPrice: 45.99,
|
||||
totalInversions: 120
|
||||
}
|
||||
}
|
||||
totalParks: 0,
|
||||
totalCoasters: 0,
|
||||
totalVisitorsPerMonth: 500000, // bleibt statisch, da nicht aus API
|
||||
averageTicketPrice: 45.99, // bleibt statisch, da nicht aus API
|
||||
totalInversions: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
// Parks abrufen
|
||||
const parksRes = await fetch('http://localhost:3000/api/parks');
|
||||
const parks = await parksRes.json();
|
||||
this.stats.totalParks = parks.length;
|
||||
|
||||
// Coaster abrufen
|
||||
const coastersRes = await fetch('http://localhost:3000/api/coasters');
|
||||
const coasters = await coastersRes.json();
|
||||
this.stats.totalCoasters = coasters.length;
|
||||
|
||||
// Summe der Inversionen berechnen
|
||||
this.stats.totalInversions = coasters.reduce((sum: number, coaster: any) => sum + coaster.inversions, 0);
|
||||
} catch (err) {
|
||||
console.error('Fehler beim Laden der Statistiken:', err);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<title>Datenbank-Statistiken - CoasterDB</title>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user