summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Controller
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-06 11:15:19 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-06 11:15:19 +0200
commitb2824fcfb9ef1fcd9b09d74c472aa783d6fe0db5 (patch)
tree06581073223bab6577987be420478c9393f35fb5 /lib/DBInfoscreen/Controller
parent9bdae29a17e9342eb85db11d97935789492e7dc7 (diff)
add wagonorder helper
Diffstat (limited to 'lib/DBInfoscreen/Controller')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm51
1 files changed, 3 insertions, 48 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index c1d952c..f8426c5 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -105,47 +105,6 @@ sub log_api_access {
return;
}
-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_no}/${wr_link}";
-
- if ( my $content = $cache->get($url) ) {
- return $content eq 'y' ? 1 : undef;
- }
-
- $ua->request_timeout(2);
- my $res = eval { $ua->head($url)->result };
-
- if ($@) {
- return;
- }
- if ( $res->is_error ) {
- $cache->set( $url, 'n' );
- return;
- }
- else {
- $cache->set( $url, 'y' );
- return 1;
- }
-}
-
sub get_results_for {
my ( $backend, $station, %opt ) = @_;
my $data;
@@ -455,13 +414,9 @@ sub render_train {
$departure->{trip_id} = $self->hafas->get_tripid($result);
- if (
- $departure->{wr_link}
- and not check_wagonorder_with_wings(
- $self->ua, $self->app->cache_iris_main,
- $result, $departure->{wr_link}
- )
- )
+ if ( $departure->{wr_link}
+ and
+ not $self->wagonorder->is_available( $result, $departure->{wr_link} ) )
{
$departure->{wr_link} = undef;
}