This commit is contained in:
Cryptkeeper!
2017-03-14 17:07:58 -05:00
committed by GitHub
parent f1dfe2e21b
commit ac0ea0d5d7
11 changed files with 146 additions and 126 deletions

View File

@ -7,6 +7,8 @@ exports.setup = function() {
db.serialize(function() {
db.run('CREATE TABLE IF NOT EXISTS pings (timestamp BIGINT NOT NULL, ip TINYTEXT, playerCount MEDIUMINT)');
db.run('CREATE INDEX IF NOT EXISTS ip_index ON pings (ip, playerCount)');
db.run('CREATE INDEX IF NOT EXISTS timestamp_index on PINGS (timestamp)');
});
exports.log = function(ip, timestamp, playerCount) {
@ -19,6 +21,14 @@ exports.setup = function() {
insertStatement.finalize();
};
exports.getTotalRecord = function(ip, callback) {
db.all("SELECT MAX(playerCount) FROM pings WHERE ip = ?", [
ip
], function(err, data) {
callback(data[0]['MAX(playerCount)']);
});
};
exports.queryPings = function(duration, callback) {
var currentTime = util.getCurrentTimeMs();
@ -29,4 +39,4 @@ exports.setup = function() {
callback(data);
});
};
};
};