summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-12-04 21:06:39 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-12-04 21:06:39 +0100
commit9c2e83fcaacc760df8815169ba0e805cfc5c199c (patch)
treef83628d89f582e7d7c67ba21e7bcc78792a804d3
parent1ed38fb0ba23389338a4eba439fc9ab521564fda (diff)
Journeys: get_connection_targets: automatically try lower thresholdsHEAD2.17.28main
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm
index e0f1e83..bce475f 100755
--- a/lib/Travelynx/Model/Journeys.pm
+++ b/lib/Travelynx/Model/Journeys.pm
@@ -2150,10 +2150,15 @@ sub get_connection_targets {
order_by => { -desc => 'count' }
}
);
- my @destinations
- = $res->hashes->grep( sub { shift->{count} >= $min_count } )
- ->map( sub { shift->{dest} } )
- ->each;
+ my @all_destinations = $res->hashes->each;
+ my @destinations;
+
+ while ( not @destinations and $min_count > 0 ) {
+ @destinations = map { $_->{dest} }
+ grep { $_->{count} >= $min_count } @all_destinations;
+ $min_count--;
+ }
+
@destinations = $self->{stations}->get_by_evas(
backend_id => $opt{backend_id},
evas => [@destinations]