avoid stale data when marking cancelled arrivals
This commit is contained in:
parent
a830acc698
commit
6cbbc2b16f
3 changed files with 29 additions and 4 deletions
|
@ -136,9 +136,26 @@ sub run {
|
||||||
);
|
);
|
||||||
if ( $train->arrival_is_cancelled ) {
|
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
|
# check out (adds a cancelled journey and resets journey state
|
||||||
# to destination selection)
|
# to destination selection)
|
||||||
$self->app->checkout( $arr, 0, $uid );
|
$self->app->checkout( $arr, 0, $uid );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->app->add_route_timestamps( $uid, $train, 0 );
|
$self->app->add_route_timestamps( $uid, $train, 0 );
|
||||||
|
|
|
@ -165,9 +165,10 @@
|
||||||
% }
|
% }
|
||||||
% if ($journey->{extra_data}{cancelled_destination}) {
|
% if ($journey->{extra_data}{cancelled_destination}) {
|
||||||
<p style="margin-bottom: 2ex;">
|
<p style="margin-bottom: 2ex;">
|
||||||
Der Halt in <b><%= $journey->{extra_data}{cancelled_destination} %></b>
|
Der Halt an der Zielstation <b><%=
|
||||||
entfällt. Der Zugausfall wurde bereits vermerkt. Bitte wähle ein
|
$journey->{extra_data}{cancelled_destination} %></b> entfällt.
|
||||||
neues Reiseziel.
|
Die zugehörige Fahrt wurde bereits als ausgefallen eingetragen.
|
||||||
|
Bitte wähle ein neues Reiseziel.
|
||||||
</p>
|
</p>
|
||||||
% }
|
% }
|
||||||
% if (@{$journey->{messages} // []} or @{$journey->{extra_data}{qos_msg} // []}) {
|
% if (@{$journey->{messages} // []} or @{$journey->{extra_data}{qos_msg} // []}) {
|
||||||
|
|
|
@ -125,6 +125,13 @@
|
||||||
% }
|
% }
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</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]) {
|
% if (@{$journey->{messages} // []} > 0 and $journey->{messages}[0]) {
|
||||||
<p style="margin-bottom: 2ex;">
|
<p style="margin-bottom: 2ex;">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
Loading…
Reference in a new issue