diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-02-13 18:35:42 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-02-13 18:35:42 +0100 |
commit | 6cbbc2b16f059a0d2b1f65a371e3c1e1f4c11fde (patch) | |
tree | e98ae1650d2969c7f2d15ca07ed1ed1be23d9d36 | |
parent | a830acc69877e204e5136e0862959164691683ca (diff) |
avoid stale data when marking cancelled arrivals1.14.9
-rw-r--r-- | lib/Travelynx/Command/work.pm | 19 | ||||
-rw-r--r-- | templates/_checked_in.html.ep | 7 | ||||
-rw-r--r-- | templates/_public_status_card.html.ep | 7 |
3 files changed, 29 insertions, 4 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm index 9658ff6..04ea95b 100644 --- a/lib/Travelynx/Command/work.pm +++ b/lib/Travelynx/Command/work.pm @@ -136,9 +136,26 @@ sub run { ); if ( $train->arrival_is_cancelled ) { + # depending on the amount of users in transit, some time may + # have passed between fetching $entry from the database and + # now. Ensure that the user is still checked into this train + # before calling checkout to mark the cancellation. + if ( + $db->select( + 'in_transit', + 'count(*) as count', + { + user_id => $uid, + train_no => $train->train_no, + checkout_station_id => $arr + } + )->hash->{count} + ) + { # check out (adds a cancelled journey and resets journey state # to destination selection) - $self->app->checkout( $arr, 0, $uid ); + $self->app->checkout( $arr, 0, $uid ); + } } else { $self->app->add_route_timestamps( $uid, $train, 0 ); diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep index 4edb1a6..e81de60 100644 --- a/templates/_checked_in.html.ep +++ b/templates/_checked_in.html.ep @@ -165,9 +165,10 @@ % } % if ($journey->{extra_data}{cancelled_destination}) { <p style="margin-bottom: 2ex;"> - Der Halt in <b><%= $journey->{extra_data}{cancelled_destination} %></b> - entfällt. Der Zugausfall wurde bereits vermerkt. Bitte wähle ein - neues Reiseziel. + Der Halt an der Zielstation <b><%= + $journey->{extra_data}{cancelled_destination} %></b> entfällt. + Die zugehörige Fahrt wurde bereits als ausgefallen eingetragen. + Bitte wähle ein neues Reiseziel. </p> % } % if (@{$journey->{messages} // []} or @{$journey->{extra_data}{qos_msg} // []}) { diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index 6979ad7..810c4b8 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -125,6 +125,13 @@ % } </div> </p> + % if ($journey->{extra_data}{cancelled_destination}) { + <p style="margin-bottom: 2ex;"> + <i class="material-icons tiny" aria-hidden="true">error</i> + Der Halt an der Zielstation <b><%= + $journey->{extra_data}{cancelled_destination} %></b> entfällt. + </p> + % } % if (@{$journey->{messages} // []} > 0 and $journey->{messages}[0]) { <p style="margin-bottom: 2ex;"> <ul> |