More docs, total user count MCI and stat
This commit is contained in:
12
core/bbs.js
12
core/bbs.js
@@ -354,6 +354,18 @@ function initialize(cb) {
|
||||
});
|
||||
});
|
||||
},
|
||||
function initUserCount(callback) {
|
||||
const User = require('./user.js');
|
||||
User.getUserCount((err, count) => {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
const StatLog = require('./stat_log');
|
||||
StatLog.setNonPersistentSystemStat(SysProps.TotalUserCount, count);
|
||||
return callback(null);
|
||||
});
|
||||
},
|
||||
function initMessageStats(callback) {
|
||||
return require('./message_area.js').startup(callback);
|
||||
},
|
||||
|
||||
@@ -304,6 +304,10 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)
|
||||
// :TODO: ?? - Total users on system
|
||||
|
||||
TU : function totalSystemUsers() {
|
||||
return StatLog.getSystemStatNum(SysProps.TotalUserCount) || 1;
|
||||
},
|
||||
|
||||
LC : function lastCallerUserName() { // Obv/2
|
||||
const lastLogin = StatLog.getSystemStat(SysProps.LastLogin) || {};
|
||||
return lastLogin.userName || 'N/A';
|
||||
|
||||
@@ -37,4 +37,6 @@ module.exports = {
|
||||
|
||||
SystemMemoryStats : 'system_memory_stats', // object { totalBytes, freeBytes }; non-persistent
|
||||
SystemLoadStats : 'system_load_stats', // object { average, current }; non-persistent
|
||||
|
||||
TotalUserCount : 'user_total_count', // non-persistent
|
||||
};
|
||||
|
||||
13
core/user.js
13
core/user.js
@@ -793,6 +793,19 @@ module.exports = class User {
|
||||
);
|
||||
}
|
||||
|
||||
static getUserCount(cb) {
|
||||
userDb.get(
|
||||
`SELECT count() AS user_count
|
||||
FROM user;`,
|
||||
(err, row) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
return cb(null, row.user_count);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static getUserList(options, cb) {
|
||||
const userList = [];
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||
// Totals
|
||||
totalCalls : StatLog.getSystemStatNum(SysProps.LoginCount),
|
||||
totalPosts : StatLog.getSystemStatNum(SysProps.MessageTotalCount),
|
||||
//totalUsers :
|
||||
totalUsers : StatLog.getSystemStatNum(SysProps.TotalUserCount),
|
||||
totalFiles : fileAreaStats.totalFiles || 0,
|
||||
totalFileBytes : fileAreaStats.totalFileBytes || 0,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user