summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl21
1 files changed, 10 insertions, 11 deletions
diff --git a/index.pl b/index.pl
index b12a274..2782520 100644
--- a/index.pl
+++ b/index.pl
@@ -439,7 +439,7 @@ get '/bar' => sub {
return;
};
-get '/top10' => sub {
+get '/top' => sub {
my $self = shift;
my $where_clause = '1=1';
@@ -462,19 +462,18 @@ get '/top10' => sub {
(scheduled_time, train_id) where $where_clause
};
$rates[$msgnum] = $self->app->dbh->selectall_arrayref($query)->[0][0];
-
- say "$msgnum: " . $rates[$msgnum] / $total;
}
my @argsort = reverse sort { $rates[$a] <=> $rates[$b] } ( 1 .. 99 );
-
- for my $i (@argsort[0 .. 10]) {
- printf("%s: %.2f%%\n", $translation{$i}, $rates[$i] * 100 / $total);
- }
-
- say join(' ', @argsort[0 .. 10]);
-
- $self->render( 'intro', );
+ my @toplist = map {
+ [
+ $translation{$_} // $_,
+ sprintf( '%.2f%%', $rates[$_] * 100 / $total ),
+ $rates[$_]
+ ]
+ } @argsort;
+
+ $self->render( 'toplist', toplist => \@toplist );
return;
};