From cabf159f46e5027e6191f82d3621b9ba9898cb61 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 15 Dec 2019 13:42:11 +0100 Subject: Handle Berlin Ringbahn and other transfer-at-destination trains Requires Travel::Status::DE::IRIS v1.38 (not released yet) --- lib/Travelynx.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/Travelynx.pm') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 73c221a..9f1a3a8 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -272,6 +272,7 @@ sub startup { station => $station, main_cache => $self->app->cache_iris_main, realtime_cache => $self->app->cache_iris_rt, + keep_transfers => 1, lookbehind => 20, datetime => DateTime->now( time_zone => 'Europe/Berlin' ) ->subtract( minutes => $lookbehind ), @@ -627,7 +628,18 @@ sub startup { my $journey = $db->select( 'in_transit', '*', { user_id => $uid } ) ->expand->hash; - my ($train) = List::Util::first { $_->train_id eq $train_id } + + # Note that a train may pass the same station several times. + # Notable example: S41 / S42 ("Ringbahn") both starts and + # terminates at Berlin Südkreuz + my ($train) = List::Util::first { + $_->train_id eq $train_id + and $_->sched_arrival + and $_->sched_arrival->epoch > $user->{sched_departure}->epoch + } + @{ $status->{results} }; + + $train //= List::Util::first { $_->train_id eq $train_id } @{ $status->{results} }; # When a checkout is triggered by a checkin, there is an edge case -- cgit v1.2.3