summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-12-04 22:07:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-12-04 22:07:20 +0100
commitd791825123607e1aa43268521c6204ec16f12868 (patch)
tree55e29e7c83ddbeff8b97dae57886563d71f29c46 /lib
parenteadeec069ba505576c592b2265baba11c3edafa8 (diff)
maintenance: remove polyline code. polylines were added more than two years ago
Diffstat (limited to 'lib')
-rw-r--r--lib/Travelynx/Command/maintenance.pm88
1 files changed, 0 insertions, 88 deletions
diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm
index 60667b7..ddd8345 100644
--- a/lib/Travelynx/Command/maintenance.pm
+++ b/lib/Travelynx/Command/maintenance.pm
@@ -183,94 +183,6 @@ sub run {
);
$tx->commit;
}
-
- # Add estimated polylines to journeys logged before 2020-01-28
-
- $tx = $db->begin;
-
- say 'Adding polylines to journeys logged before 2020-01-28';
- my $no_polyline
- = $db->select( 'journeys', 'count(*) as count', { polyline_id => undef } )
- ->hash;
- say "Checking $no_polyline->{count} journeys ...";
-
- for my $journey (
- $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 pretend 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' ],
- {
- 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);
- }
- }
- 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
- = $db->select( 'journeys', 'count(*) as count', { polyline_id => undef } )
- ->hash;
- say "Done! Remaining journeys without polyline: " . $remaining->{count};
-
- $tx->commit;
}
1;