diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-22 17:59:50 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-22 17:59:50 +0100 |
commit | 8aced49bc38a6eee94b18e3c97a87f6fd2401e5d (patch) | |
tree | 37b54b2067a52e4e952840fd0428ba9687b13bae /lib/Travelynx.pm | |
parent | 57f47d2a3caf380ca32b4230e81aecf41e72c63a (diff) |
Log unknown route entries on checkout
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-x | lib/Travelynx.pm | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 07e0c4c..387d4de 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -284,6 +284,21 @@ sub startup { } ); + $self->helper( + 'grep_unknown_stations' => sub { + my ( $self, @stations ) = @_; + + my @unknown_stations; + for my $station (@stations) { + my $station_info = get_station($station); + if ( not $station_info ) { + push( @unknown_stations, $station ); + } + } + return @unknown_stations; + } + ); + # Returns (journey id, error) # Must be called during a transaction. # Must perform a rollback on error. @@ -699,6 +714,15 @@ sub startup { }, { user_id => $uid } ); + if ($has_arrived) { + my @unknown_stations + = $self->grep_unknown_stations( $train->route ); + if (@unknown_stations) { + $self->app->log->warn( + 'Encountered unknown stations: ' + . join( ', ', @unknown_stations ) ); + } + } } $journey @@ -889,15 +913,11 @@ sub startup { return 'Zugfahrten mit über 500 km/h? Schön wär\'s.'; } if ( $journey->{edited} & 0x0010 ) { - my @unknown_stations; - for my $station ( @{ $journey->{route} } ) { - my $station_info = get_station( $station->[0] ); - if ( not $station_info ) { - push( @unknown_stations, $station->[0] ); - } - } + my @unknown_stations + = $self->grep_unknown_stations( map { $_->[0] } + @{ $journey->{route} } ); if (@unknown_stations) { - return 'Unbekannte Stationen: ' + return 'Unbekannte Station(en): ' . join( ', ', @unknown_stations ); } } |