Subversion Repositories LCARS

Compare Revisions

Last modification

Ignore whitespace Rev 30 → Rev 31

/trunk/tools/network/news/newsstat/newsstat.pl
15,17 → 15,17
## newsstat.pl
## Copyright (C) 2011, 2012 Thomas Lahn <startrek@PointedEars.de>
## Based on work by Garry Knight et al.
##
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
 
98,7 → 98,7
 
## The name of the group to do stats for
my $newsgroup_name = $ARGV[0];
$newsgroup_name or usage();
$newsgroup_name // usage();
 
## Check for removal flags
my $ix;
249,7 → 249,7
 
## Disregard article if timestamp is not in range
dmsg($timestamp) if DEBUG;
if ( $timestamp < $start or $timestamp >= $end )
if ( $timestamp < $start || $timestamp >= $end )
{
dmsg("Posting on $date ignored.") if DEBUG;
return;
264,11 → 264,11
my $filesize = -s $filename; # get total size of file
$totsize += $filesize; # bump total sizes of all files
 
if ( ( not defined $earliest ) or $timestamp < $earliest )
if ( ( not defined $earliest ) || $timestamp < $earliest )
{
$earliest = $timestamp;
}
elsif ( ( not defined $latest ) or $timestamp > $latest )
elsif ( ( not defined $latest ) || $timestamp > $latest )
{
$latest = $timestamp;
}
306,7 → 306,7
 
## The User-Agent and/or X-Newsreader fields
## for User-Agent by poster
my $ua = $msg->study('User-Agent') or $msg->study('X-Newsreader');
my $ua = $msg->study('User-Agent') // $msg->study('X-Newsreader');
if ( defined $ua )
{
$data{$poster}{'agent'} = $ua;
367,7 → 367,7
}
## are we in a quote line?
## Bill Unruh uses ] quotes, and another poster uses ::
elsif ( m{^\s*[>\]]}o or m{^\s*::}o )
elsif ( m{^\s*[>\]]}o || m{^\s*::}o )
{
## bump count of quoted chrs
$data{$poster}{'quoted'} += length($_);
395,10 → 395,9
{
my $msg = shift;
 
my $ua =
$msg->study('User-Agent')
or $msg->study('X-Newsreader')
or $msg->study('X-Mailer');
my $ua = $msg->study('User-Agent') // $msg->study('X-Newsreader')
// $msg->study('X-Mailer');
 
if ( not defined $ua )
{
my $org = $msg->study('Organization');
672,7 → 671,7
( 'precision' => 1, 'mode' => 'iec' ) );
printf __"Total number of user agents: %d\n",
$formatter->format_number( scalar keys %agents );
print "\n", "=" x 76, "\n" ;
print "\n", "=" x 76, "\n";
########################################
## Show posters by article count Sec 1;
########################################
738,6 → 737,8
#####################################
## Show top posters for original text
#####################################
my $topposters_real = 0;
 
unless ( $skipSec{3} )
{
if ( keys %data < $topposters )
748,6 → 749,7
{
$count = $topposters;
}
 
printf "%s\n",
centred(
__x(
757,7 → 759,6
76
);
print "=" x 76, "\n";
my $i = 0;
foreach my $poster (
sort { $data{$b}{percent} <=> $data{$a}{percent} }
keys %data
766,9 → 767,10
next if $data{$poster}{quoted} == 0;
next if $data{$poster}{count} < 5;
my $name = substr( $poster, 0, 63 );
printf "%2d. %-63s : %02.2f%%\n", $i + 1, rpad( $poster, 63, "." ),
printf "%2d. %-63s : %02.2f%%\n", $topposters_real + 1,
rpad( $poster, 63, "." ),
$data{$poster}{percent};
last if ( ++$i == $count );
last if ( ++$topposters_real == $count );
}
print "\n", "=" x 76, "\n";
}
776,6 → 778,9
########################################
## Show bottom posters for original text
########################################
 
$skipSec{4} = ( $topposters_real <= $topposters ) unless defined $skipSec{4};
 
unless ( $skipSec{4} )
{
if ( keys %data < $topposters )
786,6 → 791,7
{
$count = $topposters;
}
 
printf "%s\n",
centred(
__x(