From 35338125bcf5c503ec57b857ed2d11c547eca4ab Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 26 Jul 2022 13:19:29 +0200 Subject: departure board: move get_connecting_trains call to controller this is in preparation for turning it into a promise --- lib/Travelynx/Controller/Traveling.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'lib') 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} ); -- cgit v1.2.3