summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-02-24 18:49:50 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-02-24 18:49:50 +0100
commit7b1b16de6e87902d072fc33c87d29db93979bcb0 (patch)
tree1fc38422808067c88feed79c027a637de11ff858
parenta4f9f523e287fda3e5cce5fcc47521634c530310 (diff)
perltidy
-rw-r--r--index.pl50
1 files 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"),
};