Просмотр исходного кода

Patch from Phil Gregory to fix the bug with most referenced nicks, where
"number of uses" wasn't being incremented for every alias

Morten Brix Pedersen 24 лет назад
Родитель
Сommit
ec17e14242
1 измененных файлов с 17 добавлено и 0 удалено
  1. 17 0
      modules/Pisg/Parser/Logfile.pm

+ 17 - 0
modules/Pisg/Parser/Logfile.pm

@@ -75,6 +75,7 @@ sub analyze
         }
         }
 
 
         _pick_random_lines(\%stats, \%lines);
         _pick_random_lines(\%stats, \%lines);
+	_uniquify_nicks(\%stats);
 
 
         my ($sec,$min,$hour) = gmtime(time() - $starttime);
         my ($sec,$min,$hour) = gmtime(time() - $starttime);
         $stats{processtime} =
         $stats{processtime} =
@@ -465,6 +466,22 @@ sub _pick_random_lines
     }
     }
 }
 }
 
 
+sub _uniquify_nicks {
+    my ($stats) = @_;
+
+    foreach my $word (keys %{ $stats->{wordcounts} }) {
+	my $realnick = find_alias($word);
+
+	# The lc() is an attempt at being case insensitive.
+	if (lc($realnick) ne lc($word)) {
+	    $stats->{wordcounts}{$realnick} += $stats->{wordcounts}{$word};
+	    $stats->{wordnicks}{$realnick}   = $stats->{wordnicks}{$word};
+	    delete $stats->{wordcounts}{$word};
+	    delete $stats->{wordnicks}{$word};
+	}
+    }
+}
+
 sub _strip_mirccodes
 sub _strip_mirccodes
 {
 {
     my $line = shift;
     my $line = shift;