More docs, total user count MCI and stat

This commit is contained in:
Bryan Ashby
2022-05-01 19:58:00 -06:00
parent 44505f664a
commit d0db38a544
9 changed files with 57 additions and 5 deletions

View File

@@ -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);
},

View File

@@ -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';

View File

@@ -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
};

View File

@@ -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 = [];

View File

@@ -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,