From 4a8844eebeecc61d26b0fd9b3f6dbdfe5d5f0be3 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 5 Jan 2024 16:46:42 +0100 Subject: journeyMatch: handle duplicate train numbers again --- lib/DBInfoscreen/Helper/HAFAS.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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}, -- cgit v1.2.3