summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-11-12 19:13:38 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2019-11-12 19:13:38 +0100
commitead18f1212cb8f7978db567b805b717488677219 (patch)
treeb60de5efdcc8c83956bb25f8eba13b387ae068fa /lib
parent44830735398e2d2cadad50c1fe6a59da2f3d5fe8 (diff)
Fix implicit checkout when checking in from a related station1.9.10
Previously, realtime data was missing in this case
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 84310d9..d7508dc 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -554,6 +554,21 @@ sub startup {
my ($train)
= first { $_->train_id eq $train_id } @{ $status->{results} };
+ # When a checkout is triggered by a checkin, there is an edge case
+ # with related stations.
+ # Assume a user travels from A to B1, then from B2 to C. B1 and B2 are
+ # relatd stations (e.g. "Frankfurt Hbf" and "Frankfurt Hbf(tief)").
+ # Now, if they check in for the journey from B2 to C, and have not yet
+ # checked out of the previous train, $train is undef as B2 is not B1.
+ # Redo the request with with_related => 1 to avoid this case.
+ # While at it, we increase the lookahead to handle long journeys as
+ # well.
+ if ( not $train ) {
+ $status = $self->get_departures( $station, 120, 180, 1 );
+ ($train)
+ = first { $_->train_id eq $train_id } @{ $status->{results} };
+ }
+
# Store the intended checkout station regardless of this operation's
# success.
my $new_checkout_station_id = $self->get_station_id(