diff options
Diffstat (limited to 'lib/DBInfoscreen/Controller')
| -rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 25 | ||||
| -rw-r--r-- | lib/DBInfoscreen/Controller/Wagenreihung.pm | 40 |
2 files changed, 36 insertions, 29 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 4a46821..0787896 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -854,21 +854,24 @@ sub render_train { = ( $wagonorder_req, $occupancy_req, $stationinfo_req, $route_req ); if ( $departure->{wr_dt} ) { - $self->wagonorder->get_p( - train_type => $result->type, - train_number => $result->train_no, - datetime => $departure->{wr_dt}, - eva => $departure->{eva} + $self->dbris->get_wagonorder_p( + train_type => $result->type, + train_no => $result->train_no, + datetime => $departure->{wr_dt}, + eva => $departure->{eva} )->then( sub { - my ( $wr_json, $wr_param ) = @_; + my ($wr) = @_; eval { - my $wr - = Travel::Status::DE::DBRIS::Formation->new( - json => $wr_json ); + $wr = $wr->result; $departure->{wr} = $wr; - $departure->{wr_link} = join( '&', - map { $_ . '=' . $wr_param->{$_} } keys %{$wr_param} ); + $departure->{wr_link} = sprintf( + 'tt=%s&tn=%s&dt=%d&eva=%d', + $result->type, + $result->train_no, + $departure->{wr_dt}->clone->set_time_zone('UTC')->epoch, + $departure->{eva} + ); $departure->{wr_text} = join( q{ • }, map { $_->desc_short } grep { $_->desc_short } $wr->groups ); diff --git a/lib/DBInfoscreen/Controller/Wagenreihung.pm b/lib/DBInfoscreen/Controller/Wagenreihung.pm index b9f0ee3..43a04f3 100644 --- a/lib/DBInfoscreen/Controller/Wagenreihung.pm +++ b/lib/DBInfoscreen/Controller/Wagenreihung.pm @@ -10,6 +10,7 @@ use Mojo::Util qw(b64_encode b64_decode); use utf8; +use DateTime; use Travel::Status::DE::DBRIS::Formation; sub handle_wagenreihung_error { @@ -30,25 +31,27 @@ sub wagenreihung { my ($self) = @_; my $exit_side = $self->param('e'); - my $train_type = $self->param('category'); - my $train_no = $self->param('number'); - my $train = "${train_type} ${train_no}"; + my $train_type = $self->param('tt'); + my $train_no = $self->param('tn'); + my $eva = $self->param('eva'); + my $dt = DateTime->from_epoch( + epoch => $self->param('dt'), + time_zone => 'UTC' + ); + + my $train = "${train_type} ${train_no}"; $self->render_later; - $self->wagonorder->get_p( param => $self->req->query_params->to_hash ) - ->then( + $self->dbris->get_wagonorder_p( + train_type => $train_type, + train_no => $train_no, + datetime => $dt, + eva => $eva, + )->then( sub { - my ($json) = @_; - my $wr; - eval { - $wr - = Travel::Status::DE::DBRIS::Formation->new( json => $json ); - }; - if ($@) { - $self->handle_wagenreihung_error( $train, scalar $@ ); - return; - } + my ($status) = @_; + my $wr = $status->result; if ( $exit_side and $exit_side =~ m{^a} ) { if ( $wr->sectors and defined $wr->direction ) { @@ -172,10 +175,11 @@ sub wagenreihung { wref => $wref, exit_dir => $exit_dir, hide_opts => 1, - ts => $json->{ts}, + + #ts => $json->{ts}, ); } - )->catch( + )->catch( sub { my ($err) = @_; @@ -183,7 +187,7 @@ sub wagenreihung { $err // "Unbekannter Fehler" ); return; } - )->wait; + )->wait; } |
