From ef2e5640f3efc52ac0aec0d0b282ded23b6b2986 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Fri, 7 Jun 2019 22:00:20 +1000 Subject: [PATCH] Expanded stats page --- server/statistics.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/statistics.js b/server/statistics.js index 8d7aae8..2930b9b 100644 --- a/server/statistics.js +++ b/server/statistics.js @@ -4,12 +4,16 @@ require('dotenv').config(); const round = (x) => Math.round(x * 100) / 100; const statisticsRequest = (connection) => (req, res) => { - let query = 'SELECT COUNT(*) AS playerCount, SUM(gold) / COUNT(*) AS goldAverage FROM profiles;'; + let query = 'SELECT COUNT(*) AS playerCount, SUM(gold) / COUNT(*) AS goldAverage, SUM(recruits) AS recruitTotal, SUM(soldiers) AS soldierTotal, SUM(scientists) AS scientistTotal, SUM(spies) AS spyTotal FROM profiles;'; connection.query(query, (err, results) => { if (err) throw err; let playerCount = results[0].playerCount; let goldAverage = results[0].goldAverage; + let recruitTotal = results[0].recruitTotal; + let soldierTotal = results[0].soldierTotal; + let scientistTotal = results[0].scientistTotal; + let spyTotal = results[0].spyTotal; //determine the correct tick rate based on the current gold average //NOTE: copy/pasted @@ -33,6 +37,10 @@ const statisticsRequest = (connection) => (req, res) => { 'Player Count': playerCount, 'Active Players': activity, 'Active Percentage': { string: `${activePercentage}%`, color: activePercentage >= 10 ? 'lightgreen' : activePercentage >= 5 ? 'yellow' : 'red'}, + 'Recruits Total': recruitTotal, + 'Soldier Total': soldierTotal, + 'Scientist Total': scientistTotal, + 'Spy Total': { string: '[Classified]', color: 'red' }, 'Gold Average': `${round(goldAverage)}`, 'Tick Rate': `${tickRate} minutes`, 'Next Tick': `${nextTick} minute${nextTick === 1 ? '' : 's'} from now`