From 20839febf8c42cb5140553aa06623bee4ab32d59 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 14 Apr 2024 19:20:46 +0200 Subject: [PATCH] included building number in plot/event --- backend/src/controllers/StatsController.ts | 19 ++++++++++--------- frontend/src/pages/Stats.jsx | 10 ++++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/backend/src/controllers/StatsController.ts b/backend/src/controllers/StatsController.ts index 9b91939..be9a992 100644 --- a/backend/src/controllers/StatsController.ts +++ b/backend/src/controllers/StatsController.ts @@ -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()) { diff --git a/frontend/src/pages/Stats.jsx b/frontend/src/pages/Stats.jsx index 8fac8ba..589c3ef 100644 --- a/frontend/src/pages/Stats.jsx +++ b/frontend/src/pages/Stats.jsx @@ -84,8 +84,8 @@ const Stats = props => { } title={"Total number of regions"} value={parseInt(generalStats.regionCount).toLocaleString()}/> - } title={"Finished Buildings"} - value={parseInt(generalStats.totalBuildings).toLocaleString()}/> + } title={"Total Buildings (finished / started)"} + value={parseInt(generalStats.totalFinishedBuildings).toLocaleString() + " / " + parseInt(generalStats.totalBuildings).toLocaleString()}/> } 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"}/> @@ -93,9 +93,11 @@ const Stats = props => { value={numberWithCommas(generalStats.totalFinishedArea) + " m²"} valueSmall={"this is about " + ((generalStats.totalFinishedArea / 357386000000) * 100).toFixed(10).toLocaleString() + "% of Germany's area"}/> } title={"Event Area of Germany"} - value={generalStats.totalEventArea ? numberWithCommas(generalStats.totalEventArea) + " m²" : "Data not available"}/> + value={generalStats.totalEventArea ? numberWithCommas(generalStats.totalEventArea) + " m²" : "Data not available"} + valueSmall={"total number of event buildings: " + parseInt(generalStats.totalEventBuildings).toLocaleString()}/> } title={"Plot Area of Germany"} - value={generalStats.totalPlotArea ? numberWithCommas(generalStats.totalPlotArea) + " m²" : "Data not available"}/> + value={generalStats.totalPlotArea ? numberWithCommas(generalStats.totalPlotArea) + " m²" : "Data not available"} + valueSmall={"total number of plot buildings: " + parseInt(generalStats.totalPlotBuildings).toLocaleString()}/> Leaderboard