From 33dda200871e1819e272754354d6b7ac4423c94c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 21 Sep 2020 22:21:01 +0200 Subject: make train details work up to 20 minutes into the past --- lib/DBInfoscreen/Controller/Stationboard.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index bc2f054..9efe0c3 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -260,6 +260,13 @@ sub handle_request { $opt{with_related} = 1; } + if ($self->param('train')) { + # request results from five minutes ago to avoid train details suddenly + # becoming unavailable when its scheduled departure is reached. + $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20); + $opt{lookahead} = 200; + } + my $data = get_results_for( $backend, $station, %opt ); my $errstr = $data->{errstr}; @@ -654,6 +661,9 @@ sub train_details { $self->stash( title => 'DBF' ); $self->stash( version => $dbf_version ); + $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20); + $opt{lookahead} = 200; + my $data = get_results_for( 'iris', $station, %opt ); my $errstr = $data->{errstr}; -- cgit v1.2.3