From afd9cc5fe66b15128b9a5738420f64dda3645c0b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 May 2015 16:21:28 +0200 Subject: add cancellation filter to toplist --- index.pl | 29 +++++++++++++++++++---------- templates/filterform.html.ep | 8 ++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/index.pl b/index.pl index e45d297..3fe6d66 100644 --- a/index.pl +++ b/index.pl @@ -222,19 +222,20 @@ helper parse_filter_args => sub { my $where_clause = q{}; my %filter = ( - line => scalar $self->param('filter_line'), - train_no => scalar $self->param('filter_train_no'), - train_type => scalar $self->param('filter_train_type'), - station => scalar $self->param('filter_station'), - destination => scalar $self->param('filter_destination'), - delay_min => scalar $self->param('filter_delay_min'), - delay_max => scalar $self->param('filter_delay_max'), - date_start => scalar $self->param('filter_date_start'), - date_stop => scalar $self->param('filter_date_stop'), + line => scalar $self->param('filter_line'), + train_no => scalar $self->param('filter_train_no'), + train_type => scalar $self->param('filter_train_type'), + station => scalar $self->param('filter_station'), + destination => scalar $self->param('filter_destination'), + cancellation => scalar $self->param('filter_cancellation'), + delay_min => scalar $self->param('filter_delay_min'), + delay_max => scalar $self->param('filter_delay_max'), + date_start => scalar $self->param('filter_date_start'), + date_stop => scalar $self->param('filter_date_stop'), ); for my $key ( keys %filter ) { - $filter{$key} =~ tr{.a-zA-Z0-9öäüÖÄÜß }{}cd; + $filter{$key} =~ tr{._a-zA-Z0-9öäüÖÄÜß }{}cd; } $filter{delay_min} @@ -257,6 +258,14 @@ helper parse_filter_args => sub { if ( $filter{destination} ) { $where_clause .= " and destination = '$filter{destination}'"; } + if ( $filter{cancellation} ) { + if ( $filter{cancellation} eq 'only_cancelled' ) { + $where_clause .= ' and is_canceled'; + } + else { + $where_clause .= ' and not is_canceled'; + } + } if ( $filter{date_start} ) { $where_clause .= " and scheduled_time >= '$filter{date_start}'"; } diff --git a/templates/filterform.html.ep b/templates/filterform.html.ep index ed43634..614b36a 100644 --- a/templates/filterform.html.ep +++ b/templates/filterform.html.ep @@ -39,6 +39,14 @@ %= select_field filter_destination => $filter_opts->{destinations} +
+
+ Fahrten: +
+
+ %= select_field filter_cancellation => [['Alle' => q{}], ['Ohne Zugausfälle' => 'no_cancelled'], ['Nur Zugausfälle' => 'only_cancelled']] +
+
Verspätung zwischen -- cgit v1.2.3