Expanded stats page
This commit is contained in:
@@ -4,12 +4,16 @@ require('dotenv').config();
|
|||||||
const round = (x) => Math.round(x * 100) / 100;
|
const round = (x) => Math.round(x * 100) / 100;
|
||||||
|
|
||||||
const statisticsRequest = (connection) => (req, res) => {
|
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) => {
|
connection.query(query, (err, results) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
let playerCount = results[0].playerCount;
|
let playerCount = results[0].playerCount;
|
||||||
let goldAverage = results[0].goldAverage;
|
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
|
//determine the correct tick rate based on the current gold average
|
||||||
//NOTE: copy/pasted
|
//NOTE: copy/pasted
|
||||||
@@ -33,6 +37,10 @@ const statisticsRequest = (connection) => (req, res) => {
|
|||||||
'Player Count': playerCount,
|
'Player Count': playerCount,
|
||||||
'Active Players': activity,
|
'Active Players': activity,
|
||||||
'Active Percentage': { string: `${activePercentage}%`, color: activePercentage >= 10 ? 'lightgreen' : activePercentage >= 5 ? 'yellow' : 'red'},
|
'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)}`,
|
'Gold Average': `${round(goldAverage)}`,
|
||||||
'Tick Rate': `${tickRate} minutes`,
|
'Tick Rate': `${tickRate} minutes`,
|
||||||
'Next Tick': `${nextTick} minute${nextTick === 1 ? '' : 's'} from now`
|
'Next Tick': `${nextTick} minute${nextTick === 1 ? '' : 's'} from now`
|
||||||
|
|||||||
Reference in New Issue
Block a user