diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-03-07 22:53:43 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-03-07 22:53:43 +0100 |
commit | 9bc85128d7e02c6cb73ec08eff490200af63b730 (patch) | |
tree | 8804e232e31d7e8e77c19ea92e0c21878299d529 | |
parent | 5bc95476543793c188ba2ad373fb6ab8a41f552d (diff) |
working top10 (except not rendered yet)
-rw-r--r-- | index.pl | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -444,6 +444,7 @@ get '/top10' => sub { my $where_clause = '1=1'; my ( $filter, $filter_clause ) = $self->parse_filter_args; + my %translation = Travel::Status::DE::IRIS::Result::dump_message_codes(); my @rates; my $dbh = $self->app->dbh; @@ -462,9 +463,17 @@ get '/top10' => sub { }; $rates[$msgnum] = $self->app->dbh->selectall_arrayref($query)->[0][0]; - say $rates[$msgnum] / $total; + 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', ); return; }; |