From 9955a3b6f8692c4808ea560e5e2e168a9061bc0d Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 30 Nov 2025 20:24:46 +0100 Subject: dbris: show checkin suggestions at the top of the departure board Suggestions for connecting trains (i.e., suggestions shown in the "checked in" view) are not supported yet. This part is due for a major rewrite that moves the associated departure board request to the background worker rather than firing off a promise and delaying rendering until it has been answered. --- lib/Travelynx/Controller/Traveling.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/Travelynx/Controller/Traveling.pm') diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 3b46775..7e5bc82 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -1203,6 +1203,8 @@ sub station { } } + my @suggestions; + my $promise; if ($dbris_service) { if ( $station !~ m{ [@] L = \d+ }x ) { @@ -1304,6 +1306,36 @@ sub station { if ( $station =~ m{ [@] O = (? [^@]+ ) [@] }x ) { $status->{station_name} = $+{name}; } + + my ($eva) = ( $station =~ m{ [@] L = (\d+) }x ); + my $backend_id + = $self->stations->get_backend_id( dbris => $dbris_service ); + my @destinations = $self->journeys->get_connection_targets( + uid => $uid, + backend_id => $backend_id, + eva => $eva + ); + + for my $dep (@results) { + destination: for my $dest (@destinations) { + if ( $dep->destination + and $dep->destination eq $dest->{name} ) + { + push( @suggestions, [ $dep, $dest ] ); + next destination; + } + for my $via_name ( $dep->via ) { + if ( $via_name eq $dest->{name} ) { + push( @suggestions, [ $dep, $dest ] ); + next destination; + } + } + } + } + + @suggestions = map { $_->[0] } + sort { $a->[1] <=> $b->[1] } + map { [ $_, $_->[0]->dep->epoch ] } @suggestions; } elsif ($hafas_service) { @@ -1449,6 +1481,7 @@ sub station { related_stations => $status->{related_stations}, user_status => $user_status, can_check_out => $can_check_out, + suggestions => \@suggestions, title => "travelynx: $status->{station_name}", ); } -- cgit v1.2.3