More user/system stat constants & usage

This commit is contained in:
Bryan Ashby 2018-11-25 19:05:16 -07:00
parent e464f95924
commit ec97b3e8d4
14 changed files with 99 additions and 53 deletions

View file

@ -14,6 +14,7 @@ const FileBaseFilters = require('./file_base_filter.js');
const { formatByteSize } = require('./string_util.js');
const ANSI = require('./ansi_term.js');
const UserProps = require('./user_property.js');
const SysProps = require('./system_property.js');
// deps
const packageJson = require('../package.json');
@ -34,7 +35,7 @@ function setNextRandomRumor(cb) {
entry = entry[0];
}
const randRumor = entry && entry.log_value ? entry.log_value : '';
StatLog.setNonPeristentSystemStat('random_rumor', randRumor);
StatLog.setNonPersistentSystemStat(SysProps.NextRandomRumor, randRumor);
if(cb) {
return cb(null);
}
@ -67,12 +68,12 @@ const PREDEFINED_MCI_GENERATORS = {
VN : function version() { return packageJson.version; },
// +op info
SN : function opUserName() { return StatLog.getSystemStat('sysop_username'); },
SR : function opRealName() { return StatLog.getSystemStat('sysop_real_name'); },
SL : function opLocation() { return StatLog.getSystemStat('sysop_location'); },
SA : function opAffils() { return StatLog.getSystemStat('sysop_affiliation'); },
SS : function opSex() { return StatLog.getSystemStat('sysop_sex'); },
SE : function opEmail() { return StatLog.getSystemStat('sysop_email_address'); },
SN : function opUserName() { return StatLog.getSystemStat(SysProps.SysOpUsername); },
SR : function opRealName() { return StatLog.getSystemStat(SysProps.SysOpRealName); },
SL : function opLocation() { return StatLog.getSystemStat(SysProps.SysOpLocation); },
SA : function opAffils() { return StatLog.getSystemStat(SysProps.SysOpAffiliations); },
SS : function opSex() { return StatLog.getSystemStat(SysProps.SysOpSex); },
SE : function opEmail() { return StatLog.getSystemStat(SysProps.SysOpEmailAddress); },
// :TODO: op age, web, ?????
//
@ -189,7 +190,7 @@ const PREDEFINED_MCI_GENERATORS = {
AN : function activeNodes() { return clientConnections.getActiveConnections().length.toString(); },
TC : function totalCalls() { return StatLog.getSystemStat('login_count').toLocaleString(); },
TC : function totalCalls() { return StatLog.getSystemStat(SysProps.LoginCount).toLocaleString(); },
RR : function randomRumor() {
// start the process of picking another random one
@ -203,22 +204,22 @@ const PREDEFINED_MCI_GENERATORS = {
//
// :TODO: DD - Today's # of downloads (iNiQUiTY)
//
SD : function systemNumDownloads() { return sysStatAsString('dl_total_count', 0); },
SD : function systemNumDownloads() { return sysStatAsString(SysProps.FileDlTotalCount, 0); },
SO : function systemByteDownload() {
const byteSize = StatLog.getSystemStatNum('dl_total_bytes');
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTotalBytes);
return formatByteSize(byteSize, true); // true=withAbbr
},
SU : function systemNumUploads() { return sysStatAsString('ul_total_count', 0); },
SU : function systemNumUploads() { return sysStatAsString(SysProps.FileUlTotalCount, 0); },
SP : function systemByteUpload() {
const byteSize = StatLog.getSystemStatNum('ul_total_bytes');
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTotalBytes);
return formatByteSize(byteSize, true); // true=withAbbr
},
TF : function totalFilesOnSystem() {
const areaStats = StatLog.getSystemStat('file_base_area_stats');
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
return _.get(areaStats, 'totalFiles', 0).toLocaleString();
},
TB : function totalBytesOnSystem() {
const areaStats = StatLog.getSystemStat('file_base_area_stats');
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
const totalBytes = parseInt(_.get(areaStats, 'totalBytes', 0));
return formatByteSize(totalBytes, true); // true=withAbbr
},