From e259a5e5ddce5fea34dace29efa05910fc8f0300 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Aug 2019 21:30:59 +0200 Subject: Fix beeline distance calculation when start/stop has no geo-coordinates --- lib/Travelynx/Command/database.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/Travelynx/Command/database.pm') diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index e561373..c52a0a9 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -558,7 +558,7 @@ my @migrations = ( add column messages_new jsonb; } ); - my $res = $db->select( 'journeys', [ 'id', 'messages', 'route' ] ); + my $res = $db->select( 'journeys', [ 'id', 'messages', 'route' ] ); my $json = JSON->new; for my $journey ( $res->hashes->each ) { @@ -689,6 +689,22 @@ my @migrations = ( } ); }, + + # v15 -> v16 + # Beeline distance calculation now also works when departure or arrival + # station do not have geo-coordinates (by resorting to the first/last + # station in the route which does have geo-coordinates). Previously, + # beeline distances were reported as zero in this case. Clear caches + # to recalculate total distances per year / month. + sub { + my ($db) = @_; + $db->query( + qq{ + truncate journey_stats; + update schema_version set version = 16; + } + ); + }, ); sub setup_db { -- cgit v1.2.3