From 7b1b16de6e87902d072fc33c87d29db93979bcb0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 24 Feb 2015 18:49:50 +0100 Subject: perltidy --- index.pl | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/index.pl b/index.pl index 887008a..5b18127 100644 --- a/index.pl +++ b/index.pl @@ -26,17 +26,20 @@ app->attr( ); helper count_unique_column => sub { - my ($self, $column) = @_; + my ( $self, $column ) = @_; my $dbh = $self->app->dbh; - if (not $column) { - return scalar $dbh->selectall_arrayref("select count() from $table")->[0][0]; + if ( not $column ) { + return + scalar $dbh->selectall_arrayref("select count() from $table")->[0][0]; } - return scalar $dbh->selectall_arrayref("select count(distinct $column) from $table")->[0][0]; + return + scalar $dbh->selectall_arrayref( + "select count(distinct $column) from $table")->[0][0]; }; helper single_query => sub { - my ($self, $query) = @_; + my ( $self, $query ) = @_; return scalar $self->app->dbh->selectall_arrayref($query)->[0][0]; }; @@ -45,23 +48,34 @@ helper globalstats => sub { my ($self) = @_; my $dbh = $self->app->dbh; - my $stations = [ map { Travel::Status::DE::IRIS::Stations::get_station($_)->[1] } - @{ $self->app->dbh->selectcol_arrayref( - "select distinct station from $table") } ]; + my $stations = [ + map { Travel::Status::DE::IRIS::Stations::get_station($_)->[1] } @{ + $self->app->dbh->selectcol_arrayref( + "select distinct station from $table") + } + ]; my $ret = { - departures => $self->count_unique_column(), + departures => $self->count_unique_column(), stationlist => $stations, - stations => $self->count_unique_column('station'), - realtime => $self->single_query("select count() from $table where delay is not null"), - realtime_rate => $self->single_query("select avg(delay is not null) from $table"), - ontime => $self->single_query("select count() from $table where delay < 1"), + stations => $self->count_unique_column('station'), + realtime => $self->single_query( + "select count() from $table where delay is not null"), + realtime_rate => + $self->single_query("select avg(delay is not null) from $table"), + ontime => + $self->single_query("select count() from $table where delay < 1"), ontime_rate => $self->single_query("select avg(delay < 1) from $table"), - days => $self->count_unique_column('strftime("%Y%m%d", scheduled_time, "unixepoch")'), - delayed => $self->single_query("select count() from $table where delay > 5"), - delayed_rate => $self->single_query("select avg(delay > 5) from $table"), - canceled => $self->single_query("select count() from $table where is_canceled > 0"), - canceled_rate => $self->single_query("select avg(is_canceled > 0) from $table"), + days => $self->count_unique_column( + 'strftime("%Y%m%d", scheduled_time, "unixepoch")'), + delayed => + $self->single_query("select count() from $table where delay > 5"), + delayed_rate => + $self->single_query("select avg(delay > 5) from $table"), + canceled => $self->single_query( + "select count() from $table where is_canceled > 0"), + canceled_rate => + $self->single_query("select avg(is_canceled > 0) from $table"), delay_sum => $self->single_query("select sum(delay) from $table"), delay_avg => $self->single_query("select avg(delay) from $table"), }; -- cgit v1.2.3