summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-08-31 17:41:38 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-08-31 17:41:38 +0200
commit39746c144b1bcfccaaae1dc9534c3017c4814bf5 (patch)
tree42d130f99ad2c654679c771edfccdbf8ea86273f /lib
parent5cae00129a4b79802b97e48e9cd316b203e7d4af (diff)
Increase default lookahead to three hours; respect $DBFAKEDISPLAY_LOOKAHEAD
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen.pm1
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm13
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index cd97398..12da336 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -33,6 +33,7 @@ sub startup {
spare => $ENV{DBFAKEDISPLAY_SPARE} // 2,
workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
},
+ lookahead => $ENV{DBFAKEDISPLAY_LOOKAHEAD} // 180,
source_url => 'https://github.com/derf/db-fakedisplay',
issue_url => 'https://github.com/derf/db-fakedisplay/issues',
version => $ENV{DBFAKEDISPLAY_VERSION} // qx{git describe --dirty}
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 18fa100..3ff5a69 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -265,6 +265,7 @@ sub handle_request {
my %opt = (
cache_iris_main => $self->app->cache_iris_main,
cache_iris_rt => $self->app->cache_iris_rt,
+ lookahead => $self->config->{lookahead}
);
my $api_version = $Travel::Status::DE::IRIS::VERSION;
@@ -315,21 +316,17 @@ sub handle_request {
$self->stash( input => $station );
$self->param( input => $station );
- if ( $template eq 'json' ) {
- $opt{lookahead} = 120;
- }
-
if ($with_related) {
$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.
+ # request results from twenty 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;
+ $opt{lookahead} = $self->config->{lookahead} + 20;
}
my $data = get_results_for( $station, %opt );
@@ -816,7 +813,7 @@ sub station_train_details {
$opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
->subtract( minutes => 20 );
- $opt{lookahead} = 200;
+ $opt{lookahead} = $self->config->{lookahead} + 20;
my $data = get_results_for( $station, %opt );
my $errstr = $data->{errstr};