diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-05 16:28:51 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-05 16:28:51 +0100 |
commit | ea6d13144c105e7ae04fb2baed0189b8ecda9bdb (patch) | |
tree | 7ac176f0a11c47a9a9bd6c64e813681068d24a06 /lib/DBInfoscreen/Controller | |
parent | e7efe6de232445e3ef7816db4661670f7839ba7a (diff) |
train details: show expected utilization (via marudor.de)
Diffstat (limited to 'lib/DBInfoscreen/Controller')
-rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index b65aedb..a09a1df 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1,4 +1,5 @@ package DBInfoscreen::Controller::Stationboard; + # Copyright (C) 2011-2020 Daniel Friesel # # SPDX-License-Identifier: BSD-2-Clause @@ -457,6 +458,7 @@ sub render_train { $self->render_later; my $wagonorder_req = Mojo::Promise->new; + my $utilization_req = Mojo::Promise->new; my $stationinfo_req = Mojo::Promise->new; my $route_req = Mojo::Promise->new; @@ -477,9 +479,26 @@ sub render_train { return; } )->wait; + $self->marudor->get_train_utilization( train => $result )->then( + sub { + my ( $first, $second ) = @_; + $departure->{utilization} = [ $first, $second ]; + return; + }, + sub { + $departure->{utilization} = undef; + return; + } + )->finally( + sub { + $utilization_req->resolve; + return; + } + )->wait; } else { $wagonorder_req->resolve; + $utilization_req->resolve; } $self->wagonorder->get_stationinfo_p( $result->station_uic )->then( @@ -646,7 +665,8 @@ sub render_train { )->wait; # Defer rendering until all requests have completed - Mojo::Promise->all( $wagonorder_req, $stationinfo_req, $route_req )->then( + Mojo::Promise->all( $wagonorder_req, $utilization_req, $stationinfo_req, + $route_req )->then( sub { $self->render( $template // '_train_details', |