From 7ea8332a524fe5d53e7f34a42aa8bd67092294f4 Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sat, 26 Dec 2015 14:02:10 -0600 Subject: [PATCH] Fix issues when logToDatabase is disabled. --- app.js | 30 +++++++++++++++++------------- config.json | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 005bc5d..227fa42 100644 --- a/app.js +++ b/app.js @@ -89,20 +89,22 @@ function pingAll() { // The same mechanic from trimUselessPings is seen here. // If we dropped the ping, then to avoid destroying the graph, ignore it. // However if it's been too long since the last successful ping, we'll send it anyways. - if (!lastGraphPush[network.ip] || (timeMs - lastGraphPush[network.ip] >= 60 * 1000 && res) || timeMs - lastGraphPush[network.ip] >= 70 * 1000) { - lastGraphPush[network.ip] = timeMs; + if (config.logToDatabase) { + if (!lastGraphPush[network.ip] || (timeMs - lastGraphPush[network.ip] >= 60 * 1000 && res) || timeMs - lastGraphPush[network.ip] >= 70 * 1000) { + lastGraphPush[network.ip] = timeMs; - // Don't have too much data! - util.trimOldPings(graphData); + // Don't have too much data! + util.trimOldPings(graphData); - graphData[network.ip].push([timeMs, res ? res.players.online : 0]); + graphData[network.ip].push([timeMs, res ? res.players.online : 0]); - // Send the update. - server.io.sockets.emit('updateHistoryGraph', { - ip: network.ip, - players: (res ? res.players.online : 0), - timestamp: timeMs - }); + // Send the update. + server.io.sockets.emit('updateHistoryGraph', { + ip: network.ip, + players: (res ? res.players.online : 0), + timestamp: timeMs + }); + } } }); })(servers[i]); @@ -161,8 +163,10 @@ function startServices() { }); client.on('requestHistoryGraph', function() { - // Send them the big 24h graph. - client.emit('historyGraph', graphData); + if (config.logToDatabase) { + // Send them the big 24h graph. + client.emit('historyGraph', graphData); + } }); }); diff --git a/config.json b/config.json index f9558e0..46339dc 100644 --- a/config.json +++ b/config.json @@ -188,6 +188,6 @@ "pingAll": 2000, "connectTimeout": 1500 }, - "logToDatabase": true, + "logToDatabase": false, "graphDuration": 86400000 }