From bc642114e5f32158fe9687e4325709882e313cbb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 31 Mar 2015 21:57:49 +0200 Subject: add date filter --- index.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'index.pl') diff --git a/index.pl b/index.pl index 50a0c19..54f2db1 100644 --- a/index.pl +++ b/index.pl @@ -229,6 +229,8 @@ helper parse_filter_args => sub { 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'), ); for my $key ( keys %filter ) { @@ -255,6 +257,12 @@ helper parse_filter_args => sub { if ( $filter{destination} ) { $where_clause .= " and destination = '$filter{destination}'"; } + if ( $filter{date_start} ) { + $where_clause .= " and scheduled_time >= '$filter{date_start}'"; + } + if ( $filter{date_stop} ) { + $where_clause .= " and scheduled_time < '$filter{date_stop}'"; + } if ( defined $filter{delay_min} ) { $where_clause .= " and delay >= $filter{delay_min}"; } @@ -612,6 +620,14 @@ get '/bar' => sub { ) ); } + if ( $self->param('filter_date_start') ) { + push( @title_filter_strings, + 'ab ' . $self->param('filter_date_start') ); + } + if ( $self->param('filter_date_stop') ) { + push( @title_filter_strings, + 'vor ' . $self->param('filter_date_stop') ); + } if (@title_filter_strings) { $title .= ' (' . join( ', ', @title_filter_strings ) . ')'; } -- cgit v1.2.3