X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=blobdiff_plain;f=gatherstats.pl;h=f1fe7deef8deb57ab5e682358b2aee9cfe56622d;hp=ae7d65dd890725cced757ce1c5178268b71f9779;hb=07c0b2589af779c33d5d35b6a7fa0e7883201674;hpb=c3973e7d0d943c1b4eb042d79c6e477c98a689a3 diff --git a/gatherstats.pl b/gatherstats.pl index ae7d65d..f1fe7de 100755 --- a/gatherstats.pl +++ b/gatherstats.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl -W +#! /usr/bin/perl # # gatherstats.pl # @@ -7,7 +7,7 @@ # # It is part of the NewsStats package. # -# Copyright (c) 2010-2012 Thomas Hochstein +# Copyright (c) 2010-2013 Thomas Hochstein # # It can be redistributed and/or modified under the same terms under # which Perl itself is published. @@ -18,8 +18,9 @@ BEGIN { 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); @@ -145,13 +146,15 @@ foreach my $Month (&ListMonth($Period)) { if (%ValidGroups) { foreach (sort keys %ValidGroups) { if (!defined($Postings{$_})) { - # expand newsgroup with hierarchies - my @Newsgroups = ParseHierarchies($_); - # add each empty newsgroup and empty hierarchies, too, as needed - foreach (@Newsgroups) { - if (!defined($Postings{$_})) { - $Postings{$_} = 0; - warn (sprintf("ADDED: %s as empty group\n",$_)); + # 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)); }; }; } @@ -203,7 +206,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 @@ -290,7 +293,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 @@ -304,8 +306,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