diff options
author | Daniel Friesel <derf@finalrewind.org> | 2023-01-18 18:13:35 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2023-01-18 18:13:35 +0100 |
commit | e9373246175a0853fb56aff4a740f4db7dda7215 (patch) | |
tree | 0cde9fbc35979d15bb9636d50004f28782c29b24 /lib/Travelynx/Model/Journeys.pm | |
parent | eb1ed1bb48d54077930d015144636f90b2fc9c15 (diff) |
landing page: show past stops if geolocation is unavailable
Diffstat (limited to 'lib/Travelynx/Model/Journeys.pm')
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 05728c0..dfe44b6 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -739,6 +739,44 @@ sub get_latest_checkout_station_id { return $res_h->{checkout_station_id}; } +sub get_latest_checkout_stations { + my ( $self, %opt ) = @_; + my $uid = $opt{uid}; + my $db = $opt{db} // $self->{pg}->db; + my $limit = $opt{limit} // 5; + + my $res = $db->select( + 'journeys_str', + [ 'arr_name', 'arr_eva' ], + { + user_id => $uid, + cancelled => 0 + }, + { + limit => $limit, + order_by => { -desc => 'real_arr_ts' } + } + ); + + if ( not $res ) { + return; + } + + my @ret; + + while ( my $row = $res->hash ) { + push( + @ret, + { + name => $row->{arr_name}, + eva => $row->{arr_eva} + } + ); + } + + return @ret; +} + sub get_nav_years { my ( $self, %opt ) = @_; |