-#! /usr/bin/perl -W
+#! /usr/bin/perl
#
# gatherstats.pl
#
push(@INC, dirname($0));
}
use strict;
+use warnings;
use NewsStats qw(:DEFAULT :TimePeriods ListNewsgroups ParseHierarchies ReadGroupList);
=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
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
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
-#! /usr/bin/perl -W
+#! /usr/bin/perl
#
# groupstats.pl
#
push(@INC, dirname($0));
}
use strict;
+use warnings;
use NewsStats qw(:DEFAULT :TimePeriods :Output :SQLHelper ReadGroupList);
"please use 'YYYY-MM', 'YYYY-MM:YYYY-MM' or 'ALL'!") if !$CaptionPeriod;
# get list of newsgroups and set expression for SQL 'WHERE' clause
# with placeholders as well as a list of newsgroup to bind to them
-my ($SQLWhereNewsgroups,@SQLBindNewsgroups) = &SQLGroupList($OptNewsgroups)
- if $OptNewsgroups;;
+my ($SQLWhereNewsgroups,@SQLBindNewsgroups);
+if ($OptNewsgroups) {
+ ($SQLWhereNewsgroups,@SQLBindNewsgroups) = &SQLGroupList($OptNewsgroups);
+ # bail out if --newsgroups is invalid
+ &Bleat(2,"--newsgroups option has an invalid format!")
+ if !$SQLWhereNewsgroups;
+}
### build SQL WHERE clause (and HAVING clause, if needed)
my ($SQLWhereClause,$SQLHavingClause);
### get length of longest newsgroup name delivered by query
### for formatting purposes
my $Field = ($GroupBy eq 'month') ? 'newsgroup' : 'month';
-my $MaxLength = &GetMaxLength($DBHandle,$Conf{'DBTableGrps'},
- $Field,$SQLWhereClause,$SQLHavingClause,
- @SQLBindNewsgroups);
+my ($MaxLength,$MaxValLength) = &GetMaxLength($DBHandle,$Conf{'DBTableGrps'},
+ $Field,'postings',$SQLWhereClause,
+ $SQLHavingClause,
+ @SQLBindNewsgroups);
### build and execute SQL query
my ($DBQuery);
$DBQuery = $DBHandle->prepare(sprintf('SELECT %s FROM %s.%s %s %s %s',
$SQLSelect,
$Conf{'DBDatabase'},$Conf{'DBTableGrps'},
- $SQLWhereClause,$SQLGroupClause,$
- SQLOrderClause));
+ $SQLWhereClause,$SQLGroupClause,
+ $SQLOrderClause));
# execute query
$DBQuery->execute(@SQLBindNewsgroups)
# output data
&OutputData($OptFormat,$OptComments,$GroupBy,$Precision,
$OptCheckgroupsFile ? $ValidGroups : '',
- $OptFileTemplate,$DBQuery,$MaxLength);
+ $OptFileTemplate,$DBQuery,$MaxLength,$MaxValLength);
### close handles
$DBHandle->disconnect;
(one newgroup name per line; everything after the first whitespace on each
line is ignored). All other newsgroups will be removed from output.
+ Contrary to B<gatherstats>, I<filename> is not a template, but refers to
+ a single file in checkgroups format.
+
=item B<-r>, B<--report> I<default|average|sums>
Choose the report type: I<default>, I<average> or I<sums>
de.comp.datenbanken.misc has not been considered even though it has 38
postings in total, because it has less than 25 postings in every single
- month. If you want to list all newsgroups with more than 25 postings U<in
- total>, you'll have to set the boundary type to I<sum>, see below.
+ month. If you want to list all newsgroups with more than 25 postings
+ I<in total>, you'll have to set the boundary type to I<sum>, see below.
A boundary type of I<level> will show only those newsgroups - at all -
that satisfy the boundaries in each and every single month. With the above
de.comp.datenbanken.ms-access 293
de.comp.datenbanken.mysql has not been considered because it had less than
- 25 postings in 2012-02.
+ 25 postings in 2012-02 (only).
You can use that to get a list of newsgroups that have more (or less) then
- x postings during the whole reporting period.
+ x postings in every month during the whole reporting period.
A boundary type of I<average> will show only those newsgroups - at all -that
satisfy the boundaries on average. With the above list of newsgroups and