Explorar el Código

make bignumberthreshold a perl expression

Christoph Berg hace 22 años
padre
commit
d85b5fc96c
Se han modificado 6 ficheros con 25 adiciones y 8 borrados
  1. 2 1
      docs/CREDITS
  2. 4 0
      docs/Changelog
  3. 3 2
      docs/pisg-doc.xml
  4. 1 1
      modules/Pisg.pm
  5. 12 1
      modules/Pisg/HTMLGenerator.pm
  6. 3 3
      modules/Pisg/Parser/Logfile.pm

+ 2 - 1
docs/CREDITS

@@ -99,7 +99,8 @@ And all the other contributors:
    | perlbot logfile support
    | perlbot logfile support
  * Christoph Berg <cb@df7cb.de>
  * Christoph Berg <cb@df7cb.de>
    | NFiles and UserPics options, wildcards for random user pictures,
    | NFiles and UserPics options, wildcards for random user pictures,
-   | wildcard and regexp support for IgnoreWords, FoulWords, ViolentWords.
+     wildcard and regexp support for IgnoreWords, FoulWords, ViolentWords,
+     Charset conversion support, BigNumbersThreshold option, ...
  * Nathan Poznick
  * Nathan Poznick
    | Ability to specify multiple LogFiles and LogDirs.
    | Ability to specify multiple LogFiles and LogDirs.
 
 

+ 4 - 0
docs/Changelog

@@ -1,8 +1,12 @@
 pisg (x.xx)
 pisg (x.xx)
+   Changes by Morten Brix Pedersen:
    * Fix problem with number of rows shown when a nick has been ignored.
    * Fix problem with number of rows shown when a nick has been ignored.
    (thanks, Chris Thornhill)
    (thanks, Chris Thornhill)
+   Changes by Christoph Berg:
+   * Make BigNumbersThreshold a perl expression; defaults to sqrt($lines).
 
 
 pisg (0.58) - Thu Sep, 9th 2004
 pisg (0.58) - Thu Sep, 9th 2004
+   Changes by Morten Brix Pedersen:
    * Added new option, ShowFoulDecimals which configures the number of
    * Added new option, ShowFoulDecimals which configures the number of
    decimals used in statistics in foul numbers. (thanks, Thorbjörn Svensson)
    decimals used in statistics in foul numbers. (thanks, Thorbjörn Svensson)
    * Fix wrong references of nicks (thanks, Sascha Wessel)
    * Fix wrong references of nicks (thanks, Sascha Wessel)

+ 3 - 2
docs/pisg-doc.xml

@@ -2276,12 +2276,13 @@
     <para>
     <para>
     Pisg will ignore users with less than this setting lines in the "questions
     Pisg will ignore users with less than this setting lines in the "questions
     asked", "shouts loudest", "CAPSLOCK", "longest line", "most sad", and "most
     asked", "shouts loudest", "CAPSLOCK", "longest line", "most sad", and "most
-    happy" sections.
+    happy" sections. This setting is eval'ed as a Perl expression; $lines is
+    the total number of lines parsed. The default is the square root of lines.
     </para>
     </para>
     </refsect1>
     </refsect1>
     <refsect1>
     <refsect1>
     <title>Default</title>
     <title>Default</title>
-    <para> 100 </para>
+    <para> sqrt($lines) </para>
     </refsect1>
     </refsect1>
     </refentry>
     </refentry>
 
 

+ 1 - 1
modules/Pisg.pm

@@ -169,7 +169,7 @@ sub get_default_config_settings
         minquote => 25,
         minquote => 25,
         maxquote => 65,
         maxquote => 65,
         quotewidth => 80,
         quotewidth => 80,
-        bignumbersthreshold => 100,
+        bignumbersthreshold => 'sqrt($lines)',
         wordlength => 5,
         wordlength => 5,
         activenicks => 25,
         activenicks => 25,
         activenicks2 => 30,
         activenicks2 => 30,

+ 12 - 1
modules/Pisg/HTMLGenerator.pm

@@ -37,6 +37,17 @@ sub new
         }
         }
     }
     }
 
 
+    if($self->{cfg}->{bignumbersthreshold} !~ /^\d*$/) { # threshold is not a number
+        my $t = $self->{cfg}->{bignumbersthreshold};
+        $t =~ s/\$lines/($self->{stats}->{parsedlines})/g;
+        my $t2 = eval "$t";
+        if($@) {
+            print STDERR "Error when evaluating bignumbersthreshold '$t'.\n";
+            $t2 = 100;
+        }
+        $self->{cfg}->{bignumbersthreshold} = $t2 < 1 ? 1 : int($t2);
+    }
+
     bless($self, $type);
     bless($self, $type);
     return $self;
     return $self;
 }
 }
@@ -54,7 +65,7 @@ sub create_output
 
 
     my $fname = $self->{cfg}->{outputfile};
     my $fname = $self->{cfg}->{outputfile};
     $fname =~ s/\%t/$self->{cfg}->{outputtag}/g;
     $fname =~ s/\%t/$self->{cfg}->{outputtag}/g;
-    print "Now generating HTML($fname)...\n"
+    print "Now generating HTML in $fname with BigNumbersThreshold $self->{cfg}->{bignumbersthreshold}...\n"
         unless ($self->{cfg}->{silent});
         unless ($self->{cfg}->{silent});
 
 
     open (OUTPUT, "> $fname") or
     open (OUTPUT, "> $fname") or

+ 3 - 3
modules/Pisg/Parser/Logfile.pm

@@ -113,7 +113,7 @@ sub analyze
         $stats{processtime}{mins} = sprintf('%02d', $min);
         $stats{processtime}{mins} = sprintf('%02d', $min);
         $stats{processtime}{secs} = sprintf('%02d', $sec);
         $stats{processtime}{secs} = sprintf('%02d', $sec);
 
 
-        print "Channel analyzed succesfully in $processtime on ",
+        print "Channel analyzed successfully in $processtime on ",
         scalar localtime(time()), "\n"
         scalar localtime(time()), "\n"
             unless ($self->{cfg}->{silent});
             unless ($self->{cfg}->{silent});
 
 
@@ -247,7 +247,7 @@ sub _parse_file
     my $self = shift;
     my $self = shift;
     my ($stats, $lines, $file, $state) = @_;
     my ($stats, $lines, $file, $state) = @_;
 
 
-    print "Analyzing log($file) in '$self->{cfg}->{format}' format...\n"
+    print "Analyzing log $file in '$self->{cfg}->{format}' format...\n"
         unless ($self->{cfg}->{silent});
         unless ($self->{cfg}->{silent});
 
 
     if ($file =~ /.bz2?$/ && -f $file) {
     if ($file =~ /.bz2?$/ && -f $file) {
@@ -522,7 +522,7 @@ sub _parse_file
 
 
     close(LOGFILE);
     close(LOGFILE);
 
 
-    print "Finished analyzing log, $stats->{days} days total.\n"
+    print "Finished analyzing log with $stats->{totallines} lines, total: $stats->{days} days, $stats->{parsedlines} lines.\n"
         unless ($self->{cfg}->{silent});
         unless ($self->{cfg}->{silent});
 }
 }