476 |
my $nr = $1 || 10; |
my $nr = $1 || 10; |
477 |
|
|
478 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
479 |
select nick,count(*) from log group by nick order by count desc limit $nr |
select |
480 |
|
nick, |
481 |
|
count(*) as count, |
482 |
|
sum(length(message)) as len |
483 |
|
from log |
484 |
|
group by nick |
485 |
|
order by len desc,count desc |
486 |
|
limit $nr |
487 |
}); |
}); |
488 |
$sth->execute(); |
$sth->execute(); |
489 |
$res = "Top $nr users: "; |
$res = "Top $nr users: "; |
490 |
my @users; |
my @users; |
491 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
492 |
push @users,$row->{nick} . ': ' . $row->{count}; |
push @users,$row->{nick} . ': ' . $row->{count} . '/' . $row->{len} . '=' . sprintf("%.2f", $row->{len}/$row->{count}); |
493 |
} |
} |
494 |
$res .= join(" | ", @users); |
$res .= join(" | ", @users); |
495 |
} elsif ($msg =~ m/^last.*?\s*(\d*)/i) { |
} elsif ($msg =~ m/^last.*?\s*(\d*)/i) { |