summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-03-07 22:53:43 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-03-07 22:53:43 +0100
commit9bc85128d7e02c6cb73ec08eff490200af63b730 (patch)
tree8804e232e31d7e8e77c19ea92e0c21878299d529
parent5bc95476543793c188ba2ad373fb6ab8a41f552d (diff)
working top10 (except not rendered yet)
-rw-r--r--index.pl11
1 files changed, 10 insertions, 1 deletions
diff --git a/index.pl b/index.pl
index a6c48c7..b12a274 100644
--- a/index.pl
+++ b/index.pl
@@ -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;
};