+ MCI: PT - total messages posted today (non-private)

+ MCI: TP - total messages/posts on system (non-private, includes imports, only counts *current*, not all of time)
* Move some stats to startup() calls
* Fix some DATE() comparisons in SQL to use 'localtime' as our timestamps include TZ
* Update luciano_blocktronics SYSSTAT to show more info
This commit is contained in:
Bryan Ashby 2018-11-27 21:21:00 -07:00
parent fb13381bb5
commit 6cce013187
12 changed files with 98 additions and 26 deletions

View File

@ -127,15 +127,16 @@
mainMenuSystemStats: { mainMenuSystemStats: {
mci: { mci: {
BN1: { width: 17 } BN1: { width: 17 }
VL2: { width: 17 } VN2: { width: 17 }
OS3: { width: 33 } OS3: { width: 33 }
SC4: { width: 33 } SC4: { width: 33 }
DT5: { width: 33 }
CT6: { width: 33 }
AN7: { width: 6 } AN7: { width: 6 }
ND8: { width: 6 } ND8: { width: 6 }
TC9: { width: 6 } TC9: { width: 6 }
TT11: { width: 6 } TT11: { width: 6 }
PT12: { width: 6 }
TP13: { width: 6 }
NV14: { width: 17 }
} }
} }

View File

@ -263,17 +263,6 @@ function initialize(cb) {
} }
); );
}, },
function initFileAreaStats(callback) {
const getAreaStats = require('./file_base_area.js').getAreaStats;
getAreaStats( (err, stats) => {
if(!err) {
const StatLog = require('./stat_log.js');
StatLog.setNonPersistentSystemStat(SysProps.FileBaseAreaStats, stats);
}
return callback(null);
});
},
function initCallsToday(callback) { function initCallsToday(callback) {
const StatLog = require('./stat_log.js'); const StatLog = require('./stat_log.js');
const filter = { const filter = {
@ -289,6 +278,9 @@ function initialize(cb) {
return callback(null); return callback(null);
}); });
}, },
function initMessageStats(callback) {
return require('./message_area.js').startup(callback);
},
function initMCI(callback) { function initMCI(callback) {
return require('./predefined_mci.js').init(callback); return require('./predefined_mci.js').init(callback);
}, },

View File

@ -57,7 +57,25 @@ const WellKnownAreaTags = exports.WellKnownAreaTags = {
}; };
function startup(cb) { function startup(cb) {
return cleanUpTempSessionItems(cb); async.series(
[
(callback) => {
return cleanUpTempSessionItems(callback);
},
(callback) => {
getAreaStats( (err, stats) => {
if(!err) {
StatLog.setNonPersistentSystemStat(SysProps.FileBaseAreaStats, stats);
}
return callback(null);
});
}
],
err => {
return cb(err);
}
);
} }
function isInternalArea(areaTag) { function isInternalArea(areaTag) {

View File

@ -25,6 +25,7 @@ const Config = require('./config.js').get;
const { getAddressedToInfo } = require('./mail_util.js'); const { getAddressedToInfo } = require('./mail_util.js');
const Events = require('./events.js'); const Events = require('./events.js');
const UserProps = require('./user_property.js'); const UserProps = require('./user_property.js');
const SysProps = require('./system_property.js');
// deps // deps
const async = require('async'); const async = require('async');
@ -470,7 +471,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
); );
} }
updateUserStats(cb) { updateUserAndSystemStats(cb) {
if(Message.isPrivateAreaTag(this.message.areaTag)) { if(Message.isPrivateAreaTag(this.message.areaTag)) {
Events.emit(Events.getSystemEvents().UserSendMail, { user : this.client.user }); Events.emit(Events.getSystemEvents().UserSendMail, { user : this.client.user });
if(cb) { if(cb) {
@ -480,6 +481,9 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
} }
Events.emit(Events.getSystemEvents().UserPostMessage, { user : this.client.user, areaTag : this.message.areaTag }); Events.emit(Events.getSystemEvents().UserPostMessage, { user : this.client.user, areaTag : this.message.areaTag });
StatLog.incrementNonPersistentSystemStat(SysProps.MessageTotalCount, 1);
StatLog.incrementNonPersistentSystemStat(SysProps.MessagesToday, 1);
return StatLog.incrementUserStat(this.client.user, UserProps.MessagePostCount, 1, cb); return StatLog.incrementUserStat(this.client.user, UserProps.MessagePostCount, 1, cb);
} }

View File

@ -239,7 +239,10 @@ module.exports = class Message {
filter.toUserName filter.toUserName
filter.fromUserName filter.fromUserName
filter.replyToMesageId filter.replyToMesageId
filter.newerThanTimestamp
filter.newerThanTimestamp - may not be used with |date|
filter.date - moment object - may not be used with |newerThanTimestamp|
filter.newerThanMessageId filter.newerThanMessageId
filter.areaTag - note if you want by conf, send in all areas for a conf filter.areaTag - note if you want by conf, send in all areas for a conf
*filter.metaTuples - {category, name, value} *filter.metaTuples - {category, name, value}
@ -356,7 +359,10 @@ module.exports = class Message {
}); });
if(_.isString(filter.newerThanTimestamp) && filter.newerThanTimestamp.length > 0) { if(_.isString(filter.newerThanTimestamp) && filter.newerThanTimestamp.length > 0) {
// :TODO: should be using "localtime" here?
appendWhereClause(`DATETIME(m.modified_timestamp) > DATETIME("${filter.newerThanTimestamp}", "+1 seconds")`); appendWhereClause(`DATETIME(m.modified_timestamp) > DATETIME("${filter.newerThanTimestamp}", "+1 seconds")`);
} else if(moment.isMoment(filter.date)) {
appendWhereClause(`DATE(m.modified_timestamp, "localtime") = DATE("${filter.date.format('YYYY-MM-DD')}")`);
} }
if(_.isNumber(filter.newerThanMessageId)) { if(_.isNumber(filter.newerThanMessageId)) {

View File

@ -9,12 +9,17 @@ const Log = require('./logger.js').log;
const msgNetRecord = require('./msg_network.js').recordMessage; const msgNetRecord = require('./msg_network.js').recordMessage;
const sortAreasOrConfs = require('./conf_area_util.js').sortAreasOrConfs; const sortAreasOrConfs = require('./conf_area_util.js').sortAreasOrConfs;
const UserProps = require('./user_property.js'); const UserProps = require('./user_property.js');
const StatLog = require('./stat_log.js');
const SysProps = require('./system_property.js');
// deps // deps
const async = require('async'); const async = require('async');
const _ = require('lodash'); const _ = require('lodash');
const assert = require('assert'); const assert = require('assert');
const moment = require('moment');
exports.startup = startup;
exports.shutdown = shutdown;
exports.getAvailableMessageConferences = getAvailableMessageConferences; exports.getAvailableMessageConferences = getAvailableMessageConferences;
exports.getSortedAvailMessageConferences = getSortedAvailMessageConferences; exports.getSortedAvailMessageConferences = getSortedAvailMessageConferences;
exports.getAvailableMessageAreasByConfTag = getAvailableMessageAreasByConfTag; exports.getAvailableMessageAreasByConfTag = getAvailableMessageAreasByConfTag;
@ -35,6 +40,37 @@ exports.updateMessageAreaLastReadId = updateMessageAreaLastReadId;
exports.persistMessage = persistMessage; exports.persistMessage = persistMessage;
exports.trimMessageAreasScheduledEvent = trimMessageAreasScheduledEvent; exports.trimMessageAreasScheduledEvent = trimMessageAreasScheduledEvent;
function startup(cb) {
// by default, private messages are NOT included
async.series(
[
(callback) => {
Message.findMessages( { resultType : 'count' }, (err, count) => {
if(count) {
StatLog.setNonPersistentSystemStat(SysProps.MessageTotalCount, count);
}
return callback(err);
});
},
(callback) => {
Message.findMessages( { resultType : 'count', date : moment() }, (err, count) => {
if(count) {
StatLog.setNonPersistentSystemStat(SysProps.MessagesToday, count);
}
return callback(err);
});
}
],
err => {
return cb(err);
}
);
}
function shutdown(cb) {
return cb(null);
}
function getAvailableMessageConferences(client, options) { function getAvailableMessageConferences(client, options) {
options = options || { includeSystemInternal : false }; options = options || { includeSystemInternal : false };

View File

@ -38,7 +38,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
return persistMessage(msg, callback); return persistMessage(msg, callback);
}, },
function updateStats(callback) { function updateStats(callback) {
self.updateUserStats(callback); self.updateUserAndSystemStats(callback);
} }
], ],
function complete(err) { function complete(err) {

View File

@ -155,13 +155,14 @@ const PREDEFINED_MCI_GENERATORS = {
// //
// Date/Time // Date/Time
// //
// :TODO: change to CD for 'Current Date'
DT : function date(client) { return moment().format(client.currentTheme.helpers.getDateFormat()); }, DT : function date(client) { return moment().format(client.currentTheme.helpers.getDateFormat()); },
CT : function time(client) { return moment().format(client.currentTheme.helpers.getTimeFormat()) ;}, CT : function time(client) { return moment().format(client.currentTheme.helpers.getTimeFormat()) ;},
// //
// OS/System Info // OS/System Info
// //
// https://github.com/nodejs/node-v0.x-archive/issues/25769
//
OS : function operatingSystem() { OS : function operatingSystem() {
return { return {
linux : 'Linux', linux : 'Linux',
@ -169,6 +170,9 @@ const PREDEFINED_MCI_GENERATORS = {
win32 : 'Windows', win32 : 'Windows',
sunos : 'SunOS', sunos : 'SunOS',
freebsd : 'FreeBSD', freebsd : 'FreeBSD',
android : 'Android',
openbsd : 'OpenBSD',
aix : 'IBM AIX',
}[os.platform()] || os.type(); }[os.platform()] || os.type();
}, },
@ -227,14 +231,16 @@ const PREDEFINED_MCI_GENERATORS = {
const totalBytes = parseInt(_.get(areaStats, 'totalBytes', 0)); const totalBytes = parseInt(_.get(areaStats, 'totalBytes', 0));
return formatByteSize(totalBytes, true); // true=withAbbr return formatByteSize(totalBytes, true); // true=withAbbr
}, },
PT : function messagesPostedToday() { // Obv/2
return sysStatAsString(SysProps.MessagesToday, 0);
},
TP : function totalMessagesOnSystem() { // Obv/2
return sysStatAsString(SysProps.MessageTotalCount, 0);
},
// :TODO: PT - Messages posted *today* (Obv/2)
// -> Include FTN/etc.
// :TODO: NT - New users today (Obv/2) // :TODO: NT - New users today (Obv/2)
// :TODO: FT - Files uploaded/added *today* (Obv/2) // :TODO: FT - Files uploaded/added *today* (Obv/2)
// :TODO: DD - Files downloaded *today* (iNiQUiTY) // :TODO: DD - Files downloaded *today* (iNiQUiTY)
// :TODO: TP - total message/posts on the system (Obv/2)
// -> Include FTN/etc.
// :TODO: LC - name of last caller to system (Obv/2) // :TODO: LC - name of last caller to system (Obv/2)
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY) // :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)

View File

@ -21,6 +21,8 @@ const copyFileWithCollisionHandling = require('../file_util.js').copyFileWit
const getAreaStorageDirectoryByTag = require('../file_base_area.js').getAreaStorageDirectoryByTag; const getAreaStorageDirectoryByTag = require('../file_base_area.js').getAreaStorageDirectoryByTag;
const isValidStorageTag = require('../file_base_area.js').isValidStorageTag; const isValidStorageTag = require('../file_base_area.js').isValidStorageTag;
const User = require('../user.js'); const User = require('../user.js');
const StatLog = require('../stat_log.js');
const SysProps = require('../system_property.js');
// deps // deps
const moment = require('moment'); const moment = require('moment');
@ -1261,12 +1263,12 @@ function FTNMessageScanTossModule() {
} }
} }
// we do this after such that error cases can be preseved above // we do this after such that error cases can be preserved above
if(lookupName !== message.toUserName) { if(lookupName !== message.toUserName) {
message.toUserName = localUserName; message.toUserName = localUserName;
} }
// set the meta information - used elsehwere for retrieval // set the meta information - used elsewhere for retrieval
message.meta.System[Message.SystemMetaNames.LocalToUserID] = localToUserId; message.meta.System[Message.SystemMetaNames.LocalToUserID] = localToUserId;
return callback(null); return callback(null);
}); });
@ -1277,6 +1279,10 @@ function FTNMessageScanTossModule() {
// save to disc // save to disc
message.persist(err => { message.persist(err => {
if(!message.isPrivate()) {
StatLog.incrementNonPersistentSystemStat(SysProps.MessageTotalCount, 1);
StatLog.incrementNonPersistentSystemStat(SysProps.MessagesToday, 1);
}
return callback(err); return callback(err);
}); });
} }

View File

@ -253,7 +253,7 @@ class StatLog {
if(filter.date) { if(filter.date) {
filter.date = moment(filter.date); filter.date = moment(filter.date);
sql += ` AND DATE(timestamp) = DATE("${filter.date.format('YYYY-MM-DD')}")`; sql += ` AND DATE(timestamp, "localtime") = DATE("${filter.date.format('YYYY-MM-DD')}")`;
} }
if('count' !== filter.resultType) { if('count' !== filter.resultType) {

View File

@ -15,6 +15,9 @@ module.exports = {
FileUlTotalCount : 'ul_total_count', FileUlTotalCount : 'ul_total_count',
FileUlTotalBytes : 'ul_total_bytes', FileUlTotalBytes : 'ul_total_bytes',
MessageTotalCount : 'message_post_total_count', // total non-private messages on the system; non-persistent
MessagesToday : 'message_post_today', // non-private messages posted/imported today; non-persistent
// begin +op non-persistent... // begin +op non-persistent...
SysOpUsername : 'sysop_username', SysOpUsername : 'sysop_username',
SysOpRealName : 'sysop_real_name', SysOpRealName : 'sysop_real_name',