diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-07-26 13:19:29 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-07-26 13:19:29 +0200 |
commit | 35338125bcf5c503ec57b857ed2d11c547eca4ab (patch) | |
tree | 821e5c30f228b3afef27e6fe595f007263e5b429 /lib/Travelynx/Controller/Traveling.pm | |
parent | e0b824693ff2f244c9e8e9a6ccf33d95d3ec8d2a (diff) |
departure board: move get_connecting_trains call to controller
this is in preparation for turning it into a promise
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index ce4ab8e..937c740 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -622,10 +622,15 @@ sub station { map { [ $_, $_->departure->epoch // $_->sched_departure->epoch ] } @results; + my @connecting_trains; if ($train) { @results = grep { $_->type . ' ' . $_->train_no eq $train } @results; } + else { + @connecting_trains = $self->get_connecting_trains( + eva => $status->{station_eva} ); + } $self->render( 'departures', @@ -633,19 +638,25 @@ sub station { results => \@results, station => $status->{station_name}, related_stations => $status->{related_stations}, + connections => \@connecting_trains, title => "travelynx: $status->{station_name}", ); } )->catch( sub { my ($status) = @_; - $self->render( - 'landingpage', - version => $self->app->config->{version} // 'UNKNOWN', - with_autocomplete => 1, - with_geolocation => 1, - error => $status->{errstr} - ); + if ( $status->{errstr} ) { + $self->render( + 'landingpage', + version => $self->app->config->{version} // 'UNKNOWN', + with_autocomplete => 1, + with_geolocation => 1, + error => $status->{errstr} + ); + } + else { + $self->render( 'exception', exception => $status ); + } } )->wait; $self->users->mark_seen( uid => $self->current_user->{id} ); |