summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-03-31 21:57:49 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-03-31 21:57:49 +0200
commitbc642114e5f32158fe9687e4325709882e313cbb (patch)
treec82ba743c3d6a309967c8c312542f8e27dcadc28
parent2c54ad136394f7fef01f5143ee38a2a8e3e46925 (diff)
add date filter
-rw-r--r--index.pl16
-rw-r--r--templates/bargraph.html.ep2
-rw-r--r--templates/filterform.html.ep11
3 files changed, 28 insertions, 1 deletions
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 ) . ')';
}
diff --git a/templates/bargraph.html.ep b/templates/bargraph.html.ep
index da3510e..343a5df 100644
--- a/templates/bargraph.html.ep
+++ b/templates/bargraph.html.ep
@@ -2,7 +2,7 @@
%= javascript begin
-show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>&filter_line=<%= param('filter_line') %>&filter_train_no=<%= param('filter_train_no') %>&filter_train_type=<%= param('filter_train_type') %>&filter_station=<%= param('filter_station') %>&filter_destination=<%= param('filter_destination') %>&filter_delay_min=<%= param('filter_delay_min') %>&filter_delay_max=<%= param('filter_delay_max') %>',
+show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>&filter_line=<%= param('filter_line') %>&filter_train_no=<%= param('filter_train_no') %>&filter_train_type=<%= param('filter_train_type') %>&filter_station=<%= param('filter_station') %>&filter_destination=<%= param('filter_destination') %>&filter_delay_min=<%= param('filter_delay_min') %>&filter_delay_max=<%= param('filter_delay_max') %>&filter_date_start=<%= param('filter_date_start') %>&filter_date_stop=<%= param('filter_date_stop') %>',
'<%== param('title') %>',
'<%= param('xlabel') %>', '<%= param('ylabel') %>', '<%= param('yformat') %>',
'<%= param('width') %>', '<%= param('height') %>');
diff --git a/templates/filterform.html.ep b/templates/filterform.html.ep
index 844ecb7..ed43634 100644
--- a/templates/filterform.html.ep
+++ b/templates/filterform.html.ep
@@ -48,6 +48,17 @@
und
%= text_field 'filter_delay_max', class => 'delay', placeholder => '+∞'
Minuten (inklusive).
+ </div>
+</div>
+<div class="field">
+ <div class="desc">
+ Zeitraum von
+ </div>
+ <div>
+ %= date_field 'filter_date_start', class => 'datetime'
+ (inklusive) bis
+ %= date_field 'filter_date_stop', class => 'datetime'
+ (exklusive)
%= submit_button 'Go'
</div>
</div>