summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-05-02 10:05:49 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-05-02 10:05:49 +0200
commitfb2a06c59c49e46d469e800120e907a6aad28d3f (patch)
tree000ecf701f8faf8df62f88cc0ffdb30a9159a568 /lib/Travelynx/Command
parent3de5de7db2b7eebe000c6534bfd020405921ccdc (diff)
work: Not finding a train at the destination is usually not an error1.1.0
Diffstat (limited to 'lib/Travelynx/Command')
-rw-r--r--lib/Travelynx/Command/work.pm25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index c43f920..6c84d49 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -20,10 +20,10 @@ sub run {
$db->select( 'in_transit_str', '*', { cancelled => 0 } )->hashes->each )
{
- my $uid = $entry->{user_id};
- my $dep = $entry->{dep_ds100};
- my $arr = $entry->{arr_ds100};
- my $train = $entry->{train_id};
+ my $uid = $entry->{user_id};
+ my $dep = $entry->{dep_ds100};
+ my $arr = $entry->{arr_ds100};
+ 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(