diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-02-17 21:13:07 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-02-17 21:13:07 +0100 |
commit | cc7439dd5e051904aa03e21a7a50bda106c43ae0 (patch) | |
tree | 8d0e84931ca4807ca53c61f38e6df7c5700b4433 /lib/Travelynx.pm | |
parent | a1865fa69e3a90e484e8423e256e1cb969b7e04d (diff) |
handle departure cancellation after checkin
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-x | lib/Travelynx.pm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 661572e..92d2973 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -2684,6 +2684,10 @@ sub startup { my $db = $opt{db} //= $self->pg->db; my $min_count = $opt{min_count} // 3; + if ( $opt{destination_name} ) { + return ( $opt{destination_name} ); + } + my $dest_id = $opt{eva} // $self->get_latest_dest_id(%opt); if ( not $dest_id ) { @@ -2730,6 +2734,9 @@ sub startup { if ( $use_history & 0x01 ) { $eva = $opt{eva}; } + elsif ( $opt{destination_name} ) { + $eva = $opt{eva}; + } } else { if ( $use_history & 0x02 ) { @@ -3357,6 +3364,38 @@ sub startup { } )->expand->hash; + my $latest_cancellation = $db->select( + 'journeys_str', + '*', + { + user_id => $uid, + }, + { + order_by => { -desc => 'journey_id' }, + limit => 1 + } + )->expand->hash; + + if ( $latest_cancellation and $latest_cancellation->{cancelled} ) { + if ( my $station + = $self->app->station_by_eva + ->{ $latest_cancellation->{dep_eva} } ) + { + $latest_cancellation->{dep_ds100} = $station->[0]; + $latest_cancellation->{dep_name} = $station->[1]; + } + if ( my $station + = $self->app->station_by_eva + ->{ $latest_cancellation->{arr_eva} } ) + { + $latest_cancellation->{arr_ds100} = $station->[0]; + $latest_cancellation->{arr_name} = $station->[1]; + } + } + else { + $latest_cancellation = undef; + } + if ($latest) { my $ts = $latest->{checkout_ts}; my $action_time = epoch_to_dt($ts); @@ -3375,6 +3414,7 @@ sub startup { return { checked_in => 0, cancelled => 0, + cancellation => $latest_cancellation, journey_id => $latest->{journey_id}, timestamp => $action_time, timestamp_delta => $now->epoch - $action_time->epoch, @@ -3401,6 +3441,7 @@ sub startup { return { checked_in => 0, cancelled => 0, + cancellation => $latest_cancellation, no_journeys_yet => 1, timestamp => epoch_to_dt(0), timestamp_delta => $now->epoch, |