Skip to content
Snippets Groups Projects
Commit eadba0bf authored by Tristan Greaves's avatar Tristan Greaves
Browse files

Initial support for offline message counting in msglist.js.

Added options:
 -count
 -all_subs
 -hide_zero

This allows this script to be used to create counts of messages in the groups.
Typical use: Stats on new messages in the last x days.
parent c726b671
No related branches found
No related tags found
No related merge requests found
Pipeline #2741 passed
...@@ -62,6 +62,9 @@ if(argv.indexOf('-?') >= 0 || argv.indexOf('-help') >= 0) ...@@ -62,6 +62,9 @@ if(argv.indexOf('-?') >= 0 || argv.indexOf('-help') >= 0)
writeln(" -p=<list> specify comma-separated list of property names to print"); writeln(" -p=<list> specify comma-separated list of property names to print");
writeln(" -fmt=<fmt> specify format string"); writeln(" -fmt=<fmt> specify format string");
writeln(" -hdr include list header"); writeln(" -hdr include list header");
writeln(" -count show count of messages only");
writeln(" -all_subs action for all sub areas")
writeln(" -hide_zero do not show a line if zero messages are returned")
exit(0); exit(0);
} }
require('sbbsdefs.js', 'LEN_ALIAS'); require('sbbsdefs.js', 'LEN_ALIAS');
...@@ -1553,6 +1556,9 @@ var lm_mode; ...@@ -1553,6 +1556,9 @@ var lm_mode;
var preview; var preview;
var msgbase_code; var msgbase_code;
var since; var since;
var count_only;
var all_subs;
var hide_zero;
for(var i in argv) { for(var i in argv) {
var arg = argv[i].toLowerCase(); var arg = argv[i].toLowerCase();
...@@ -1612,6 +1618,15 @@ for(var i in argv) { ...@@ -1612,6 +1618,15 @@ for(var i in argv) {
case '-hdr': case '-hdr':
list_hdr = true; list_hdr = true;
break; break;
case '-count':
count_only = true;
break;
case '-all_subs':
all_subs = true;
break;
case '-hide_zero':
hide_zero = true;
break;
default: default:
if(msgbase_code === undefined) if(msgbase_code === undefined)
msgbase_code = arg; msgbase_code = arg;
...@@ -1625,6 +1640,7 @@ for(var i in argv) { ...@@ -1625,6 +1640,7 @@ for(var i in argv) {
} }
} }
if (!all_subs) {
if(!msgbase_code) { if(!msgbase_code) {
if(js.global.bbs === undefined) { if(js.global.bbs === undefined) {
alert("No msgbase code specified"); alert("No msgbase code specified");
...@@ -1632,9 +1648,10 @@ if(!msgbase_code) { ...@@ -1632,9 +1648,10 @@ if(!msgbase_code) {
} }
msgbase_code = bbs.cursub_code; msgbase_code = bbs.cursub_code;
} }
}
var msgbase = new MsgBase(msgbase_code); var msgbase = new MsgBase(msgbase_code);
if(!msgbase.open()) { if(!msgbase.open() && !all_subs) {
alert(msgbase.error); alert(msgbase.error);
exit(); exit();
} }
...@@ -1656,7 +1673,7 @@ if(options.date_fmt === undefined) ...@@ -1656,7 +1673,7 @@ if(options.date_fmt === undefined)
options.date_fmt = "%Y-%m-%d"; options.date_fmt = "%Y-%m-%d";
// options.date_time_fmt = "%a %b %d %Y %H:%M:%S"; // options.date_time_fmt = "%a %b %d %Y %H:%M:%S";
if(!msgbase.total_msgs) { if(!msgbase.total_msgs && !all_subs) {
alert("No messages"); alert("No messages");
exit(); exit();
} }
...@@ -1744,12 +1761,36 @@ if(js.global.bbs && bbs.online) { ...@@ -1744,12 +1761,36 @@ if(js.global.bbs && bbs.online) {
js.on_exit("bbs.sys_status &= ~SS_MOFF"); js.on_exit("bbs.sys_status &= ~SS_MOFF");
bbs.sys_status |= SS_MOFF; // Disable automatic messages bbs.sys_status |= SS_MOFF; // Disable automatic messages
} else { } else {
var list = load_msgs(msgbase, which, lm_mode, /* usernumber; */0, since); var sub_list = [];
if(!list || !list.length) { if (all_subs) {
alert("No messages"); for (var sub in msg_area.sub) {
exit(0); sub_list.push(sub);
}
} else {
sub_list.push(msgbase_code)
}
for(var i = 0; i < sub_list.length; i++)
{
var local_msgbase_code = sub_list[i];
var msgbase = new MsgBase(local_msgbase_code);
if(!msgbase.open()) {
alert(msgbase.error);
exit();
} }
var list = load_msgs(msgbase, which, lm_mode, /* usernumber; */0, since);
if (count_only) {
if ( list.length || !hide_zero )
printf("%10s %-40s %5s\n", msgbase.cfg.grp_name, msgbase.cfg.description, list.length)
} else {
list_msgs_offline(msgbase, list); list_msgs_offline(msgbase, list);
}
}
exit(0); exit(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment