From 1703b8e3b454713d4f873acdb5cb400db490a152 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sun, 1 Sep 2013 17:52:21 +0200 Subject: [PATCH] Get empty 'virtual' hierarchies working. Commit b5125b1099cf5cf12beb0520d5896b9a1d7850ae was broken. We didn't add empty .ALL hierarchies as needed; we added empty (non-existant) hierarchies without appended '.ALL', and didn't add the original empty group we started with. (What's more, gatherstats didn't even start any more due to missing ex- and import of &ParseHierarchies from NewsStats.pm.) Fixes #52 (and some more breakage). Signed-off-by: Thomas Hochstein --- NewsStats.pm | 1 + gatherstats.pl | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/NewsStats.pm b/NewsStats.pm index 428719e..bfcb37b 100644 --- a/NewsStats.pm +++ b/NewsStats.pm @@ -33,6 +33,7 @@ require Exporter; SplitPeriod ListMonth ListNewsgroups + ParseHierarchies ReadGroupList OutputData FormatOutput diff --git a/gatherstats.pl b/gatherstats.pl index ae7d65d..4c539f1 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); @@ -145,13 +145,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)); }; }; } -- 2.20.1