enigma-bbs/core/stats.js
Bryan Ashby 44a0f87a24 + stats.js: public APIs for accessing various system stats. Probably needs a better name
* Fix pause placement. Wait for all views ready before placing cursor such that the prompt will display in the right spot
2015-07-28 22:31:28 -06:00

32 lines
708 B
JavaScript

/* jslint node: true */
'use strict';
var userDb = require('./database.js').dbs.user;
var async = require('async');
exports.getUserLoginHistory = getUserLoginHistory;
function getUserLoginHistory(numRequested, cb) {
numRequested = Math.max(1, numRequested);
var loginHistory = [];
userDb.each(
'SELECT user_id, user_name, timestamp ' +
'FROM user_login_history ' +
'ORDER BY timestamp DESC ' +
'LIMIT ' + numRequested + ';',
function historyRow(err, histEntry) {
loginHistory.push( {
userId : histEntry.user_id,
userName : histEntry.user_name,
timestamp : histEntry.timestamp,
} );
},
function complete(err, recCount) {
cb(err, loginHistory);
}
);
}