diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-04-16 16:29:34 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-04-16 16:29:34 +0200 |
commit | da05a0e9810eba6ba2e9792ff7efbcda2a612b5c (patch) | |
tree | 5dd19952560de7d3a5a02b0463f20d6928a9a30a /lib | |
parent | ac2a23c3faae849f3a13583bb4a3b7dc4e39fd81 (diff) |
maintenance: backpropagate polylines to route entries using pre-1.9.4 format
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Travelynx/Command/maintenance.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm index 8237e33..5965546 100644 --- a/lib/Travelynx/Command/maintenance.pm +++ b/lib/Travelynx/Command/maintenance.pm @@ -143,6 +143,20 @@ sub run { $db->select( 'journeys', [ 'id', 'route' ], { polyline_id => undef } ) ->hashes->each ) { + + # prior to v1.9.4, routes were stored as [["stop1"], ["stop2"], ...]. + # Nowadays, the common format is [["stop1", {}, null], ...]. + # entry[1] is non-empty only while checked in, entry[2] is non-null only + # if the stop is unscheduled or has been cancelled. + # + # Here, we pretened to use the new format, as we're looking for + # matching routes in more recent journeys. + # + # Note that journey->{route} is serialized JSON (i.e., a string). + # It is not deserialized for performance reasons. + $journey->{route} + =~ s/ (?<! additional ) (?<! cancelled ) "] /", {}, null]/gx; + my $ref = $db->select( 'journeys', [ 'id', 'polyline_id' ], |