Merge branch 'language' into next
[usenet/newsstats.git] / gatherstats.pl
index ae7d65d..6db137d 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -W
+#! /usr/bin/perl
 #
 # gatherstats.pl
 #
 #
 # gatherstats.pl
 #
@@ -18,8 +18,9 @@ BEGIN {
   push(@INC, dirname($0));
 }
 use strict;
   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);
 
 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{$_})) {
     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
 
 
 =head1 SYNOPSIS
 
-B<gatherstats> [B<-Vhdt>] [B<-m> I<YYYY-MM> | I<YYYY-MM:YYYY-MM>] [B<-s> I<stats] [B<-c> I<filename template>]] [B<--hierarchy> I<TLH>] [B<--rawdb> I<database table>] [B<-groupsdb> I<database table>] [B<--clientsdb> I<database table>] [B<--hostsdb> I<database table>]
+B<gatherstats> [B<-Vhdt>] [B<-m> I<YYYY-MM> | I<YYYY-MM:YYYY-MM>] [B<-s> I<stats>] [B<-c> I<filename template>]] [B<--hierarchy> I<TLH>] [B<--rawdb> I<database table>] [B<-groupsdb> I<database table>] [B<--clientsdb> I<database table>] [B<--hostsdb> I<database table>]
 
 =head1 REQUIREMENTS
 
 
 =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). 
 
 period between two month in YYYY-MM:YYYY-MM format (two month, separated
 by a colon). 
 
-
 =item B<-s>, B<--stats> I<type>
 
 Set processing type to one of I<all> and I<groups>. Defaults to all
 =item B<-s>, B<--stats> I<type>
 
 Set processing type to one of I<all> and I<groups>. 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).
 
 whitespace (so you can use a file in checkgroups format or (part of)
 your INN active file).
 
-The filename is taken from I<filename template>, amended by each B<--
-month> B<gatherstats> is processing, so that
+The filename is taken from I<filename template>, amended by each
+B<--month> B<gatherstats> is processing in the form of I<template-YYYY-MM>,
+so that
 
     gatherstats -m 2010-01:2010-12 -c checkgroups
 
 
     gatherstats -m 2010-01:2010-12 -c checkgroups
 
This page took 0.011663 seconds and 4 git commands to generate.