mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-02 07:51:52 +02:00
+ 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
This commit is contained in:
parent
4a342ba2fa
commit
44a0f87a24
5 changed files with 116 additions and 47 deletions
32
core/stats.js
Normal file
32
core/stats.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* 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);
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue