From 4cc510d7109a371f2458628e74b9cdb664eb2465 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 14 Apr 2020 18:14:19 +0200 Subject: use polyline when computing monthly/yearly distance travelled Closes #40 --- lib/Travelynx.pm | 11 ++++++----- lib/Travelynx/Command/database.pm | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 7c9e723..818205f 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1790,11 +1790,12 @@ sub startup { } my @journeys = $self->get_user_travels( - uid => $uid, - cancelled => $opt{cancelled} ? 1 : 0, - verbose => 1, - after => $interval_start, - before => $interval_end + uid => $uid, + cancelled => $opt{cancelled} ? 1 : 0, + verbose => 1, + with_polyline => 1, + after => $interval_start, + before => $interval_end ); my $stats = $self->compute_journey_stats(@journeys); diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index 22d8a93..59e41d9 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -997,6 +997,21 @@ my @migrations = ( } ); }, + + # v20 -> v21 + # After introducing polyline support, journey distance calculation diverged: + # the detail view (individual train) used the polyline, whereas monthly and + # yearly statistics were still based on beeline between intermediate stops. + # Release 1.16.0 fixes this -> ensure all caches are rebuilt. + sub { + my ($db) = @_; + $db->query( + qq{ + truncate journey_stats; + update schema_version set version = 21; + } + ); + }, ); sub setup_db { -- cgit v1.2.3