3.1.0 (#69)
This commit is contained in:
@ -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);
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user