diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-01-05 16:46:42 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-01-05 16:46:42 +0100 |
commit | 4a8844eebeecc61d26b0fd9b3f6dbdfe5d5f0be3 (patch) | |
tree | 92e5d97dd48714ffb0688ad22e023c55d2d82a7f /lib | |
parent | 5e72665cbdc6904a3162724d220e432993c71dd9 (diff) |
journeyMatch: handle duplicate train numbers again4.20.0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/DBInfoscreen/Helper/HAFAS.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 6ff147f..ad21c58 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -72,9 +72,23 @@ sub get_route_p { return Mojo::Promise->reject( "journeyMatch($opt{train_req}) found no results"); } + + my $result = $results[0]; + if ( @results > 1 ) { + for my $journey (@results) { + if ( $opt{train_origin} + and ( $journey->route )[0]->loc->name eq + $opt{train_origin} ) + { + $result = $journey; + last; + } + } + } + return Travel::Status::DE::HAFAS->new_p( journey => { - id => $results[0]->id, + id => $result->id, }, language => $opt{language}, cache => $self->{realtime_cache}, |