diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-12-15 13:42:11 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-15 13:42:11 +0100 |
commit | cabf159f46e5027e6191f82d3621b9ba9898cb61 (patch) | |
tree | 664ba07b07f6ccc96e50edd72dadd410a193a9b5 /lib/Travelynx.pm | |
parent | 7ae60f2ea44aa61ed0d9451c4389b6d7630d583e (diff) |
Handle Berlin Ringbahn and other transfer-at-destination trains
Requires Travel::Status::DE::IRIS v1.38 (not released yet)
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-x | lib/Travelynx.pm | 14 |
1 files changed, 13 insertions, 1 deletions
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 |