aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core/stats.js
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-03-14 06:26:53 +0100
committermarzavec <admin@marzavec.com>2018-03-14 06:26:53 +0100
commit39ec02d3c4cb5f5980b172d30404210de2479f0f (patch)
treeb837c9cfff94c62aa3de9880e4f7d07460734984 /server/src/commands/core/stats.js
parentstabilized modules and server cmd field (diff)
downloadhackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.tar.gz
hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.zip
Streamlined modules, server tweaks, better feedback
Diffstat (limited to 'server/src/commands/core/stats.js')
-rw-r--r--server/src/commands/core/stats.js26
1 files changed, 3 insertions, 23 deletions
diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js
index ba28319..a1abddb 100644
--- a/server/src/commands/core/stats.js
+++ b/server/src/commands/core/stats.js
@@ -1,22 +1,9 @@
/*
-
+ Description: Legacy stats output, kept for compatibility, outputs user and channel count
*/
'use strict';
-const stripIndents = require('common-tags').stripIndents;
-
-const formatTime = (time) => {
- let seconds = time[0] + time[1] / 1e9;
-
- let minutes = Math.floor(seconds / 60);
- seconds = seconds % 60;
-
- let hours = Math.floor(minutes / 60);
- minutes = minutes % 60;
- return `${hours.toFixed(0)}h ${minutes.toFixed(0)}m ${seconds.toFixed(0)}s`;
-};
-
exports.run = async (core, server, socket, data) => {
let ips = {};
let channels = {};
@@ -35,14 +22,7 @@ exports.run = async (core, server, socket, data) => {
server.reply({
cmd: 'info',
- text: stripIndents`current-connections: ${uniqueClientCount}
- current-channels: ${uniqueChannels}
- users-joined: ${(core.managers.stats.get('users-joined') || 0)}
- invites-sent: ${(core.managers.stats.get('invites-sent') || 0)}
- messages-sent: ${(core.managers.stats.get('messages-sent') || 0)}
- users-banned: ${(core.managers.stats.get('users-banned') || 0)}
- stats-requested: ${(core.managers.stats.get('stats-requested') || 0)}
- server-uptime: ${formatTime(process.hrtime(core.managers.stats.get('start-time')))}`
+ text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`
}, socket);
core.managers.stats.increment('stats-requested');
@@ -50,5 +30,5 @@ exports.run = async (core, server, socket, data) => {
exports.info = {
name: 'stats',
- description: 'Sends back current server stats to the calling client'
+ description: 'Sends back legacy server stats to the calling client'
};