-#! /usr/bin/perl -W
+#! /usr/bin/perl
#
# gatherstats.pl
#
push(@INC, dirname($0));
}
use strict;
+use warnings;
-use NewsStats qw(:DEFAULT :TimePeriods ListNewsgroups ReadGroupList);
+use NewsStats qw(:DEFAULT :TimePeriods ListNewsgroups ParseHierarchies ReadGroupList);
use DBI;
use Getopt::Long qw(GetOptions);
# count postings per group
my %Postings;
while (($_) = $DBQuery->fetchrow_array) {
- # get list oft newsgroups and hierarchies from Newsgroups:
+ # get list of newsgroups and hierarchies from Newsgroups:
my %Newsgroups = ListNewsgroups($_,$TLH,
$OptCheckgroupsFile ? \%ValidGroups : '');
# count each newsgroup and hierarchy once
if (%ValidGroups) {
foreach (sort keys %ValidGroups) {
if (!defined($Postings{$_})) {
- $Postings{$_} = 0 ;
+ # add current newsgroup as empty group
+ $Postings{$_} = 0;
warn (sprintf("ADDED: %s as empty group\n",$_));
+ # add empty hierarchies for current newsgroup as needed
+ foreach (ParseHierarchies($_)) {
+ my $Hierarchy = $_ . '.ALL';
+ if (!defined($Postings{$Hierarchy})) {
+ $Postings{$Hierarchy} = 0;
+ warn (sprintf("ADDED: %s as empty group\n",$Hierarchy));
+ };
+ };
}
};
};
-
+
# delete old data for that month
if (!$OptTest) {
$DBQuery = $DBHandle->do(sprintf("DELETE FROM %s.%s WHERE month = ?",