diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-12-27 22:12:15 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-12-27 22:12:15 +0100 |
commit | 34a19ee1bf97edcc8a58fc83bc89ed2b43717670 (patch) | |
tree | 5aa8af4fdfa75b77bf867bed34c3614355855277 /lib/Travelynx/Model/Journeys.pm | |
parent | 3156d5f372707df965933b1885137857652466f5 (diff) |
top trips: handle return trips
Diffstat (limited to 'lib/Travelynx/Model/Journeys.pm')
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 5721726..404567b 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -1342,8 +1342,20 @@ sub compute_review { my $single_trip_count = 0; for my $i ( 0 .. 3 ) { if ( $trips[$i] ) { - push( @{ $review{top_trips} }, - [ split( qr{[|]}, $trips[$i][0] ) ] ); + my ( $from, $to ) = split( qr{[|]}, $trips[$i][0] ); + my $found = 0; + for my $j ( 0 .. $i - 1 ) { + if ( $review{top_trip_count}[$j][0] eq $to + and $review{top_trip_count}[$j][2] eq $from ) + { + $review{top_trip_count}[$j][1] = '↔'; + $found = 1; + last; + } + } + if ( not $found ) { + push( @{ $review{top_trips} }, [ $from, '→', $to ] ); + } $top_trip_count += $trips[$i][1]; } } |