X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=blobdiff_plain;f=gatherstats.pl;h=64ea87b016accb7c7d8184e103c056747643af7b;hp=2bc426b93e12b82870cc3a01d7c68f8dcb324c7a;hb=95d9fe2cfd944f93036d3c584328a91d952c5c7c;hpb=93c8eae2edcb7ccb4a3fe25817908fdb0723f324 diff --git a/gatherstats.pl b/gatherstats.pl index 2bc426b..64ea87b 100755 --- a/gatherstats.pl +++ b/gatherstats.pl @@ -19,7 +19,7 @@ BEGIN { } use strict; -use NewsStats qw(:DEFAULT :TimePeriods ListNewsgroups ReadGroupList); +use NewsStats qw(:DEFAULT :TimePeriods ListNewsgroups ParseHierarchies ReadGroupList); use DBI; use Getopt::Long qw(GetOptions); @@ -132,7 +132,7 @@ foreach my $Month (&ListMonth($Period)) { # 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 @@ -145,12 +145,21 @@ foreach my $Month (&ListMonth($Period)) { 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 = ?", @@ -196,7 +205,7 @@ gatherstats - process statistical data from a raw source =head1 SYNOPSIS -B [B<-Vhdt>] [B<-m> I | I] [B<-s> I I]] [B<--hierarchy> I] [B<--rawdb> I] [B<-groupsdb> I] [B<--clientsdb> I] [B<--hostsdb> I] +B [B<-Vhdt>] [B<-m> I | I] [B<-s> I] [B<-c> I]] [B<--hierarchy> I] [B<--rawdb> I] [B<-groupsdb> I] [B<--clientsdb> I] [B<--hostsdb> I] =head1 REQUIREMENTS @@ -283,7 +292,6 @@ Set processing period to a single month in YYYY-MM format or to a time period between two month in YYYY-MM:YYYY-MM format (two month, separated by a colon). - =item B<-s>, B<--stats> I Set processing type to one of I and I. Defaults to all @@ -297,8 +305,9 @@ one group on each line and ignoring everything after the first whitespace (so you can use a file in checkgroups format or (part of) your INN active file). -The filename is taken from I, amended by each B<-- -month> B is processing, so that +The filename is taken from I, amended by each +B<--month> B is processing in the form of I, +so that gatherstats -m 2010-01:2010-12 -c checkgroups