summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-12-10 21:27:23 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-12-10 21:27:23 +0100
commita668150460042c299aa33fdc411b93313ef5a7bc (patch)
treee71284e595639e7f0c1b590e27a3f39d3c492735 /lib
parentb0822cc5a59da117d39d4ad0b21665cfd9f57315 (diff)
only link to wagon order if the train has one2.3.16
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 1935c25..79538a0 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -102,6 +102,29 @@ sub log_api_access {
return;
}
+sub check_wagonorder {
+ my ( $ua, $cache, $train, $wr_link ) = @_;
+
+ my $url
+ = "https://lib.finalrewind.org/dbdb/has_wagonorder/${train}/${wr_link}";
+
+ if ( my $content = $cache->get($url) ) {
+ return $content eq 'y' ? 1 : undef;
+ }
+
+ $ua->request_timeout(2);
+ my $res = $ua->head($url)->result;
+
+ if ( $res->is_error ) {
+ $cache->set( $url, 'n' );
+ return;
+ }
+ else {
+ $cache->set( $url, 'y' );
+ return 1;
+ }
+}
+
sub hafas_json_req {
my ( $ua, $cache, $url ) = @_;
@@ -946,6 +969,18 @@ sub handle_request {
[ $result->sched_route_post ]
)
];
+
+ if (
+ $departures[-1]{wr_link}
+ and not check_wagonorder(
+ $self->ua, $self->app->cache_iris_main,
+ $result->train_no, $departures[-1]{wr_link}
+ )
+ )
+ {
+ $departures[-1]{wr_link} = undef;
+ }
+
my ( $route_ts, $route_info ) = get_route_timestamps(
$self->ua,
$self->app->cache_iris_main,