summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-02-06 17:54:23 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-02-06 17:54:23 +0100
commitc2e0f377be954b70c1c095e441871231c603a34d (patch)
treedc14d183010127569517ff2c2f5efbeeb44700af /lib/Travelynx/Command
parent0457a53f657d887e5644331b3cca1f56fde5d371 (diff)
maintenance: consider station renames whan backpropagating polylines1.14.6
Diffstat (limited to 'lib/Travelynx/Command')
-rw-r--r--lib/Travelynx/Command/maintenance.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm
index 32a6231..8237e33 100644
--- a/lib/Travelynx/Command/maintenance.pm
+++ b/lib/Travelynx/Command/maintenance.pm
@@ -165,6 +165,35 @@ sub run {
exit(1);
}
}
+ else {
+ while ( my ( $old_name, $new_name )
+ = each %{ $self->app->renamed_station } )
+ {
+ $journey->{route} =~ s{"\Q$old_name\E"}{"$new_name"};
+ }
+ my $ref = $db->select(
+ 'journeys',
+ [ 'id', 'polyline_id' ],
+ {
+ route => $journey->{route},
+ polyline_id => { '!=', undef },
+ edited => 0,
+ },
+ { limit => 1 }
+ )->hash;
+ if ($ref) {
+ my $rows = $db->update(
+ 'journeys',
+ { polyline_id => $ref->{polyline_id} },
+ { id => $journey->{id} }
+ )->rows;
+ if ( $rows != 1 ) {
+ say STDERR
+"Database update returned $rows rows, expected 1. Rollback and abort.";
+ exit(1);
+ }
+ }
+ }
}
my $remaining