enigma-bbs/core/stats.js
Bryan Ashby ca4b99a83e * Convert all JSON configurations (*.json) to HJSON (*.hjson) which is much more flexible for a human readable and editable configuration format
* WIP "next" vs "action" changes
* options.cls is now defaulted in config.js/config.hjson (default = true)
* Notes/etc.
2015-09-08 22:08:45 -06:00

33 lines
710 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);
}
);
}