diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-11-16 23:47:18 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-11-16 23:47:18 +0100 |
commit | 783a540cb081732aa6336d5441e2ef2738ccb1cf (patch) | |
tree | 2a889102917e6a75d24783f838e6eb56b58c6d8c /lib/Travelynx | |
parent | e0187c5308b1d228cb8a651fad97af097ad94d44 (diff) |
history map: show time range; handle users with no journeys
Diffstat (limited to 'lib/Travelynx')
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 74f1e4d..3f6217b 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -422,6 +422,21 @@ sub map_history { # TODO create map-specific get_user_travels function returning EVA/DS100 station codes? my @journeys = $self->get_user_travels; + if ( not @journeys ) { + $self->render( + template => 'history_map', + with_map => 1, + station_coordinates => [], + station_pairs => [], + range_from => 0, + range_to => 0, + ); + return; + } + + my $first_departure = $journeys[-1]->{rt_departure}; + my $last_departure = $journeys[0]->{rt_departure}; + my @stations = uniq map { $_->{to_name} } @journeys; push( @stations, uniq map { $_->{from_name} } @journeys ); @stations = uniq @stations; @@ -437,7 +452,10 @@ sub map_history { my $from_index = first_index { $_ eq $journey->{from_name} } @route; my $to_index = first_index { $_ eq $journey->{to_name} } @route; - if ( $from_index == -1 or $to_index == -1 or $journey->{edited} == 0x3fff ) { + if ( $from_index == -1 + or $to_index == -1 + or $journey->{edited} == 0x3fff ) + { next; } @@ -475,7 +493,9 @@ sub map_history { template => 'history_map', with_map => 1, station_coordinates => \@station_coordinates, - station_pairs => \@station_pairs + station_pairs => \@station_pairs, + range_from => $first_departure, + range_to => $last_departure, ); } |