summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm6
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm38
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 9d32c86..357e3bd 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -376,6 +376,7 @@ sub homepage {
my ($self) = @_;
if ( $self->is_user_authenticated ) {
my $status = $self->get_user_status;
+ my @recent_targets;
if ( $status->{checked_in} ) {
if ( defined $status->{arrival_countdown}
and $status->{arrival_countdown} < ( 40 * 60 ) )
@@ -414,10 +415,15 @@ sub homepage {
return;
}
}
+ else {
+ @recent_targets = $self->journeys->get_latest_checkout_stations(
+ uid => $self->current_user->{id} );
+ }
$self->render(
'landingpage',
version => $self->app->config->{version} // 'UNKNOWN',
user_status => $status,
+ recent_targets => \@recent_targets,
with_autocomplete => 1,
with_geolocation => 1
);
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 ) = @_;