feat: display total travel distance in map view
All checks were successful
Perl Tests / perl (5.20-buster) (push) Successful in 4m34s
Perl Tests / perl (latest) (push) Successful in 4m1s
Perl Tests / perl (threaded) (push) Successful in 3m30s

Added calculation and display of total distance traveled in the travel map history view. This enhancement provides users with a quick overview of the cumulative distance covered during their journeys. The addition is beneficial for users tracking their travel metrics for personal or record-keeping purposes.
This commit is contained in:
Kumi 2024-10-14 22:04:40 +02:00
parent 95e5b593db
commit f384cfc0fe
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 12 additions and 0 deletions

View file

@ -1342,6 +1342,7 @@ sub map_history {
with_polyline => $with_polyline,
after => $filter_from,
before => $filter_until,
verbose => 1
);
if ($filter_type) {
@ -1357,12 +1358,19 @@ sub map_history {
skipped_journeys => [],
station_coordinates => [],
polyline_groups => [],
distance_traveled => 0,
);
return;
}
my $include_manual = $self->param('include_manual') ? 1 : 0;
my $total_distance = 0;
for my $journey (@journeys) {
$total_distance += $journey->{km_route} // 0;
}
my $res = $self->journeys_to_map_data(
journeys => \@journeys,
route_type => $route_type,
@ -1374,6 +1382,7 @@ sub map_history {
year => $year,
with_map => 1,
title => 'travelynx: Karte',
total_distance => $total_distance,
%{$res}
);
}

View file

@ -33,6 +33,9 @@
%= include '_map', station_coordinates => $station_coordinates, polyline_groups => $polyline_groups
%= form_for '/history/map' => begin
<p>
Gesamtdistanz: <%= sprintf("%.2f", $total_distance // 0) %> km
</p>
<p>
Detailgrad:
</p>