summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-07-26 13:19:29 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-07-26 13:19:29 +0200
commit35338125bcf5c503ec57b857ed2d11c547eca4ab (patch)
tree821e5c30f228b3afef27e6fe595f007263e5b429
parente0b824693ff2f244c9e8e9a6ccf33d95d3ec8d2a (diff)
departure board: move get_connecting_trains call to controller
this is in preparation for turning it into a promise
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm25
-rw-r--r--templates/departures.html.ep2
2 files changed, 19 insertions, 8 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} );
diff --git a/templates/departures.html.ep b/templates/departures.html.ep
index 220d951..3ef081b 100644
--- a/templates/departures.html.ep
+++ b/templates/departures.html.ep
@@ -40,7 +40,7 @@
</div>
</div>
% }
-% elsif (not param('train') and my @connections = get_connecting_trains(eva => $eva)) {
+% elsif (not param('train') and my @connections = @{stash('connections') // []}) {
% $have_connections = 1;
<div class="row">
<div class="col s12">