diff --git a/core/config.js b/core/config.js index bd152e99..73179ced 100644 --- a/core/config.js +++ b/core/config.js @@ -953,6 +953,10 @@ function getDefaultConfig() { eventScheduler : { events : { + resetDailyStats : { + schedule : 'at 12:00:01am', // note: Later.js places this right @ midnight + action : '@method:core/misc_scheduled_events.js:resetDailyStatsScheduledEvent', + }, trimMessageAreas : { // may optionally use [or ]@watch:/path/to/file schedule : 'every 24 hours', diff --git a/core/misc_scheduled_events.js b/core/misc_scheduled_events.js new file mode 100644 index 00000000..64a73ea5 --- /dev/null +++ b/core/misc_scheduled_events.js @@ -0,0 +1,18 @@ +/* jslint node: true */ +'use strict'; + +const StatLog = require('./stat_log.js'); +const SysProps = require('./system_property.js'); + +exports.resetDailyStatsScheduledEvent = resetDailyStatsScheduledEvent; + +function resetDailyStatsScheduledEvent(args, cb) { + // + // Various stats need reset daily + // + [ SysProps.LoginsToday, SysProps.MessagesToday ].forEach(prop => { + StatLog.setNonPersistentSystemStat(prop, 0); + }); + + return cb(null); +}