From aaeb81a5d230ca556fa950d0f9be0b98e85effcf Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 1 Oct 2023 07:11:58 +0200 Subject: store related stations; respect them when looking up connections --- lib/Travelynx/Model/Journeys.pm | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'lib/Travelynx/Model/Journeys.pm') diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 3fa2d96..3f2c0dd 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -1735,21 +1735,20 @@ sub get_connection_targets { return; } - my $res = $db->query( - qq{ - select - count(checkout_station_id) as count, - checkout_station_id as dest - from journeys - where user_id = ? - and checkin_station_id = ? - and real_departure > ? - group by checkout_station_id - order by count desc; + my $dest_ids = [ $dest_id, $self->{stations}->get_meta( eva => $dest_id ) ]; + + my $res = $db->select( + 'journeys', + 'count(checkout_station_id) as count, checkout_station_id as dest', + { + user_id => $uid, + checkin_station_id => $dest_ids, + real_departure => { '>', $threshold } }, - $uid, - $dest_id, - $threshold + { + group_by => ['checkout_station_id'], + order_by => { -desc => 'count' } + } ); my @destinations = $res->hashes->grep( sub { shift->{count} >= $min_count } ) -- cgit v1.2.3