From cf28090a1cba71687b5166d6bc6cf4939e3e32a0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 26 Dec 2019 10:56:58 +0100 Subject: fix wagon order for wing trains --- lib/DBInfoscreen/Controller/Stationboard.pm | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index c3c720b..9ebaca4 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -102,11 +102,26 @@ sub log_api_access { return; } -sub check_wagonorder { +sub check_wagonorder_with_wings { my ( $ua, $cache, $train, $wr_link ) = @_; + if ( check_wagonorder( $ua, $cache, $train->train_no, $wr_link ) ) { + return 1; + } + elsif ( $train->is_wing ) { + my $wing = $train->wing_of; + if ( check_wagonorder( $ua, $cache, $wing->train_no, $wr_link ) ) { + return 1; + } + } + return; +} + +sub check_wagonorder { + my ( $ua, $cache, $train_no, $wr_link ) = @_; + my $url - = "https://lib.finalrewind.org/dbdb/has_wagonorder/${train}/${wr_link}"; + = "https://lib.finalrewind.org/dbdb/has_wagonorder/${train_no}/${wr_link}"; if ( my $content = $cache->get($url) ) { return $content eq 'y' ? 1 : undef; @@ -972,9 +987,9 @@ sub handle_request { if ( $departures[-1]{wr_link} - and not check_wagonorder( - $self->ua, $self->app->cache_iris_main, - $result->train_no, $departures[-1]{wr_link} + and not check_wagonorder_with_wings( + $self->ua, $self->app->cache_iris_main, + $result, $departures[-1]{wr_link} ) ) { -- cgit v1.2.3