work: Not finding a train at the destination is usually not an error

This commit is contained in:
Daniel Friesel 2019-05-02 10:05:49 +02:00
parent 3de5de7db2
commit fb2a06c59c

View file

@ -23,7 +23,7 @@ sub run {
my $uid = $entry->{user_id};
my $dep = $entry->{dep_ds100};
my $arr = $entry->{arr_ds100};
my $train = $entry->{train_id};
my $train_id = $entry->{train_id};
$self->app->log->debug("Processing $uid");
@ -36,10 +36,10 @@ sub run {
}
my ($train)
= first { $_->train_id eq $train } @{ $status->{results} };
= first { $_->train_id eq $train_id } @{ $status->{results} };
if ( not $train ) {
die("could not find train $train at $dep\n");
die("could not find train $train_id at $dep\n");
}
$db->update(
@ -77,10 +77,19 @@ sub run {
}
my ($train)
= first { $_->train_id eq $train } @{ $status->{results} };
= first { $_->train_id eq $train_id } @{ $status->{results} };
if ( not $train ) {
die("could not find train $train at $arr\n");
if ( $entry->{real_arr_ts} ) {
die(
"could not find train $train_id at $arr -- did it disappear?\n"
);
}
else {
# If we haven't seen the train yet, its arrival is probably
# too far in the future. This is not critical.
return;
}
}
$db->update(