Add empty 'virtual' .ALL hierarchies as needed.

When using a --checkgroups file while tabulating,
valid but empty groups will be added with a posting
count of zero as needed. If all groups in a
sub-hierarchy are empty, the virtual '.ALL' group
for that sub-hierarchy was not created, though.

If local.test.dummy and local.test.binary were
both empty, both groups were added with a posting
count of '0', but local.test.ALL was not.

Now we loop through all hierarchy elements using
ParseHierarchies and add empty .ALL hierarchies as
needed.

Fixes #49.

Also fixing a typo in some comment. :-)

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2013-08-11 01:47:32 +02:00
parent 93c8eae2ed
commit b5125b1099

View file

@ -132,7 +132,7 @@ foreach my $Month (&ListMonth($Period)) {
# count postings per group # count postings per group
my %Postings; my %Postings;
while (($_) = $DBQuery->fetchrow_array) { while (($_) = $DBQuery->fetchrow_array) {
# get list oft newsgroups and hierarchies from Newsgroups: # get list of newsgroups and hierarchies from Newsgroups:
my %Newsgroups = ListNewsgroups($_,$TLH, my %Newsgroups = ListNewsgroups($_,$TLH,
$OptCheckgroupsFile ? \%ValidGroups : ''); $OptCheckgroupsFile ? \%ValidGroups : '');
# count each newsgroup and hierarchy once # count each newsgroup and hierarchy once
@ -144,9 +144,16 @@ foreach my $Month (&ListMonth($Period)) {
# add valid but empty groups if --checkgroups is set # add valid but empty groups if --checkgroups is set
if (%ValidGroups) { if (%ValidGroups) {
foreach (sort keys %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{$_})) { if (!defined($Postings{$_})) {
$Postings{$_} = 0; $Postings{$_} = 0;
warn (sprintf("ADDED: %s as empty group\n",$_)); warn (sprintf("ADDED: %s as empty group\n",$_));
};
};
} }
}; };
}; };