added new player ticker

This commit is contained in:
2019-06-08 01:55:30 +10:00
parent fa05bfd0dd
commit 3b25a7c068
+20 -12
View File
@@ -33,19 +33,27 @@ const statisticsRequest = (connection) => (req, res) => {
let activity = results[0].activity; let activity = results[0].activity;
let activePercentage = round(activity / playerCount * 100); let activePercentage = round(activity / playerCount * 100);
res.status(200).json({ let query = 'SELECT COUNT(*) AS newPlayers FROM profiles WHERE td >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)';
'Player Count': playerCount, connection.query(query, (err, results) => {
'Active Players': activity, if (err) throw err;
'Active Percentage': { string: `${activePercentage}%`, color: activePercentage >= 10 ? 'lightgreen' : activePercentage >= 5 ? 'yellow' : 'red'},
'Recruits Total': recruitTotal, let newPlayers = results[0].newPlayers;
'Soldier Total': soldierTotal,
'Scientist Total': scientistTotal, res.status(200).json({
'Spy Total': { string: '[Classified]', color: 'red' }, 'Player Count': playerCount,
'Gold Average': `${round(goldAverage)}`, 'Active Players': activity,
'Tick Rate': `${tickRate} minutes`, 'Active Percentage': { string: `${activePercentage}%`, color: activePercentage >= 10 ? 'lightgreen' : activePercentage >= 5 ? 'yellow' : 'red'},
'Next Tick': `${nextTick} minute${nextTick === 1 ? '' : 's'} from now` 'New Players': newPlayers > 0 ? { string: `${newPlayers} (Welcome aboard!)`, color: 'lightgreen' } : { string: '0', color: 'yellow' },
'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`
});
res.end();
}); });
res.end();
}); });
}); });
}; };