From f88817d98eedc3f0c99857e842127a5f4b78fba2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 31 Aug 2021 17:56:35 +0200 Subject: Add past option --- lib/DBInfoscreen/Controller/Stationboard.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 3ff5a69..77f3a7d 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -268,6 +268,12 @@ sub handle_request { lookahead => $self->config->{lookahead} ); + if ( $self->param('past') ) { + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( minutes => 60 ); + $opt{lookahead} += 60; + } + my $api_version = $Travel::Status::DE::IRIS::VERSION; $self->stash( departures => [] ); @@ -320,7 +326,7 @@ sub handle_request { $opt{with_related} = 1; } - if ( $self->param('train') ) { + if ( $self->param('train') and not $opt{datetime} ) { # request results from twenty minutes ago to avoid train details suddenly # becoming unavailable when its scheduled departure is reached. @@ -811,9 +817,16 @@ sub station_train_details { $self->stash( title => 'DBF' ); $self->stash( version => $self->config->{version} ); - $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) - ->subtract( minutes => 20 ); - $opt{lookahead} = $self->config->{lookahead} + 20; + if ( $self->param('past') ) { + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( minutes => 80 ); + $opt{lookahead} = $self->config->{lookahead} + 80; + } + else { + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( minutes => 20 ); + $opt{lookahead} = $self->config->{lookahead} + 20; + } my $data = get_results_for( $station, %opt ); my $errstr = $data->{errstr}; -- cgit v1.2.3