Skip to content

Commit

Permalink
included building number in plot/event
Browse files Browse the repository at this point in the history
  • Loading branch information
20Alexanderxx committed Apr 14, 2024
1 parent 2d940ef commit 20839fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
19 changes: 10 additions & 9 deletions backend/src/controllers/StatsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,47 @@ export default class StatsController {
buildings: true
}
});

const totalArea = sums.area;
const totalBuildings = sums.buildings;

const { _sum: plotSums } = await this.core.getPrisma().region.aggregate({
_sum: {
area: true
area: true,
buildings: true
},
where: {
isPlotRegion: true
}
});

const totalPlotArea = plotSums.area;
const totalPlotBuildings = plotSums.buildings;

const { _sum: eventSums } = await this.core.getPrisma().region.aggregate({
_sum: {
area: true
area: true,
buildings: true
},
where: {
isEventRegion: true
}
});

const totalEventArea = eventSums.area;
const totalEventBuildings = eventSums.buildings;

const { _sum: finishedSums } = await this.core.getPrisma().region.aggregate({
_sum: {
area: true
area: true,
buildings: true
},
where: {
isFinished: true
}
});

const totalFinishedArea = finishedSums.area;
const totalFinishedBuildings = finishedSums.buildings;

response.send({ regionCount, totalArea, totalBuildings, totalPlotArea, totalEventArea, totalFinishedArea });
response.send({ regionCount, totalArea, totalBuildings, totalPlotArea, totalPlotBuildings, totalEventArea, totalEventBuildings, totalFinishedArea, totalFinishedBuildings });
}

public async getLeaderboard(request: Request, response: Response) {
const errors = validationResult(request);
if (!errors.isEmpty()) {
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/pages/Stats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ const Stats = props => {
<Grid>
<Grid.Col sm={12} lg={6}><StatsCard icon={<FiList/>} title={"Total number of regions"}
value={parseInt(generalStats.regionCount).toLocaleString()}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiBuilding/>} title={"Finished Buildings"}
value={parseInt(generalStats.totalBuildings).toLocaleString()}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiBuilding/>} title={"Total Buildings (finished / started)"}
value={parseInt(generalStats.totalFinishedBuildings).toLocaleString() + " / " + parseInt(generalStats.totalBuildings).toLocaleString()}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiArea/>} title={"Total area of all regions"}
value={numberWithCommas(generalStats.totalArea) + " m²"}
valueSmall={"this is about " + ((generalStats.totalArea / 357386000000) * 100).toFixed(10).toLocaleString() + "% of Germany's area"}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiArea/>} title={"finished Area of Germany"}
value={numberWithCommas(generalStats.totalFinishedArea) + " m²"}
valueSmall={"this is about " + ((generalStats.totalFinishedArea / 357386000000) * 100).toFixed(10).toLocaleString() + "% of Germany's area"}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiBuilding/>} title={"Event Area of Germany"}
value={generalStats.totalEventArea ? numberWithCommas(generalStats.totalEventArea) + " m²" : "Data not available"}/></Grid.Col>
value={generalStats.totalEventArea ? numberWithCommas(generalStats.totalEventArea) + " m²" : "Data not available"}
valueSmall={"total number of event buildings: " + parseInt(generalStats.totalEventBuildings).toLocaleString()}/></Grid.Col>
<Grid.Col sm={12} lg={6}><StatsCard icon={<BiBuilding/>} title={"Plot Area of Germany"}
value={generalStats.totalPlotArea ? numberWithCommas(generalStats.totalPlotArea) + " m²" : "Data not available"}/></Grid.Col>
value={generalStats.totalPlotArea ? numberWithCommas(generalStats.totalPlotArea) + " m²" : "Data not available"}
valueSmall={"total number of plot buildings: " + parseInt(generalStats.totalPlotBuildings).toLocaleString()}/></Grid.Col>
</Grid>

<Title my={"md"}>Leaderboard</Title>
Expand Down

0 comments on commit 20839fe

Please sign in to comment.