_checked_out: move get_connecting_trains call to controller

This commit is contained in:
Daniel Friesel 2022-07-26 15:36:22 +02:00
parent 960de27f0e
commit 1594ba9327
No known key found for this signature in database
GPG key ID: 100D5BFB5166E005
2 changed files with 14 additions and 7 deletions

View file

@ -362,7 +362,16 @@ sub status_card {
);
}
else {
$self->render( '_checked_out', journey => $status );
my @connecting_trains;
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
if ( $now->epoch - $status->{timestamp}->epoch < ( 30 * 60 ) ) {
@connecting_trains = $self->get_connecting_trains;
}
$self->render(
'_checked_out',
journey => $status,
connections => \@connecting_trains
);
}
}

View file

@ -3,12 +3,10 @@
<span class="card-title">Ausgecheckt</span>
<p>Aus <%= $journey->{train_type} %> <%= $journey->{train_no} %>
bis <a href="/s/<%= $journey->{arr_ds100} %>"><%= $journey->{arr_name} %></a></p>
% if (now()->epoch - $journey->{timestamp}->epoch < (30*60)) {
% if (my @connections = get_connecting_trains()) {
<span class="card-title" style="margin-top: 2ex;">Verbindungen</span>
<p>Zug auswählen zum Einchecken mit Zielwahl.</p>
%= include '_connections', connections => \@connections, checkin_from => $journey->{arr_ds100};
% }
% if (my @connections = @{stash('connections') // []}) {
<span class="card-title" style="margin-top: 2ex;">Verbindungen</span>
<p>Zug auswählen zum Einchecken mit Zielwahl.</p>
%= include '_connections', connections => \@connections, checkin_from => $journey->{arr_ds100};
% }
</div>
<div class="card-action">