3.0.0
This commit is contained in:
24
lib/util.js
24
lib/util.js
@ -108,26 +108,25 @@ exports.setIntervalNoDelay = function(func, delay) {
|
||||
return task;
|
||||
};
|
||||
|
||||
exports.convertPingsToGraph = function(sqlData) {
|
||||
exports.convertServerHistory = function(sqlData) {
|
||||
var serverIps = getServerIps();
|
||||
var graphData = {};
|
||||
var highestPlayerCount = {};
|
||||
|
||||
var startTime = exports.getCurrentTimeMs();
|
||||
|
||||
for (var i = 0; i < sqlData.length; i++) {
|
||||
var entry = sqlData[i];
|
||||
|
||||
if (serverIps.indexOf(entry.ip) === -1) {
|
||||
continue;
|
||||
}
|
||||
if (serverIps.indexOf(entry.ip) === -1) continue;
|
||||
|
||||
var name = getServerNameByIp(entry.ip);
|
||||
|
||||
if (!graphData[name]) {
|
||||
graphData[name] = [];
|
||||
}
|
||||
|
||||
if (!graphData[name]) graphData[name] = [];
|
||||
graphData[name].push([entry.timestamp, entry.playerCount]);
|
||||
|
||||
if (!highestPlayerCount[entry.ip]) highestPlayerCount[entry.ip] = 0;
|
||||
if (entry.playerCount > highestPlayerCount[entry.ip]) highestPlayerCount[entry.ip] = entry.playerCount;
|
||||
}
|
||||
|
||||
// Break it into minutes.
|
||||
@ -136,9 +135,12 @@ exports.convertPingsToGraph = function(sqlData) {
|
||||
// Drop old data.
|
||||
exports.trimOldPings(graphData);
|
||||
|
||||
logger.info('Converted data structure in ' + (exports.getCurrentTimeMs() - startTime) + 'ms');
|
||||
logger.info('Parsed ' + sqlData.length + ' ping records in ' + (exports.getCurrentTimeMs() - startTime) + 'ms');
|
||||
|
||||
return graphData;
|
||||
return {
|
||||
graphData: graphData,
|
||||
highestPlayerCount: highestPlayerCount
|
||||
};
|
||||
};
|
||||
|
||||
exports.getBootTime = function() {
|
||||
@ -166,4 +168,4 @@ exports.unfurlSRV = function(hostname, port, callback) {
|
||||
}
|
||||
callback(records[0].name, records[0].port);
|
||||
})
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user