Skip to content

Commit

Permalink
Speed up history pages: Only build route datetimes when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
derf committed Dec 18, 2024
1 parent d8d11dc commit 0db5528
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
13 changes: 7 additions & 6 deletions lib/Travelynx/Controller/Profile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ sub journey_details {
}

my $journey = $self->journeys->get_single(
uid => $user->{id},
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_polyline => 1,
with_visibility => 1,
uid => $user->{id},
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_route_datetime => 1,
with_polyline => 1,
with_visibility => 1,
);

if ( not $journey ) {
Expand Down
40 changes: 22 additions & 18 deletions lib/Travelynx/Controller/Traveling.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,10 @@ sub redirect_to_station {
sub cancelled {
my ($self) = @_;
my @journeys = $self->journeys->get(
uid => $self->current_user->{id},
cancelled => 1,
with_datetime => 1
uid => $self->current_user->{id},
cancelled => 1,
with_datetime => 1,
with_route_datetime => 1
);

$self->respond_to(
Expand Down Expand Up @@ -1696,12 +1697,13 @@ sub journey_details {
}

my $journey = $self->journeys->get_single(
uid => $uid,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_polyline => 1,
with_visibility => 1,
uid => $uid,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_route_datetime => 1,
with_polyline => 1,
with_visibility => 1,
);

if ($journey) {
Expand Down Expand Up @@ -1924,10 +1926,11 @@ sub edit_journey {
}

my $journey = $self->journeys->get_single(
uid => $uid,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
uid => $uid,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_route_datetime => 1,
);

if ( not $journey ) {
Expand Down Expand Up @@ -2028,11 +2031,12 @@ sub edit_journey {

if ( not $error ) {
$journey = $self->journeys->get_single(
uid => $uid,
db => $db,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
uid => $uid,
db => $db,
journey_id => $journey_id,
verbose => 1,
with_datetime => 1,
with_route_datetime => 1,
);
$error = $self->journeys->sanity_check($journey);
}
Expand Down
11 changes: 7 additions & 4 deletions lib/Travelynx/Model/Journeys.pm
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,11 @@ sub update {
my $rows;

my $journey = $self->get_single(
uid => $uid,
db => $db,
journey_id => $journey_id,
with_datetime => 1,
uid => $uid,
db => $db,
journey_id => $journey_id,
with_datetime => 1,
with_route_datetime => 1,
);

eval {
Expand Down Expand Up @@ -656,6 +657,8 @@ sub get {
$ref->{checkout} = epoch_to_dt( $ref->{checkout_ts} );
$ref->{sched_arrival} = epoch_to_dt( $ref->{sched_arr_ts} );
$ref->{rt_arrival} = epoch_to_dt( $ref->{rt_arr_ts} );
}
if ( $opt{with_route_datetime} ) {
for my $stop ( @{ $ref->{route} } ) {
for my $k (qw(rt_arr rt_dep sched_arr sched_dep)) {
if ( $stop->[2]{$k} ) {
Expand Down

0 comments on commit 0db5528

Please sign in to comment.