From 671e518cafc03c1d8a123c65351a8a02d8d339a2 Mon Sep 17 00:00:00 2001 From: Derf Null Date: Tue, 16 May 2023 20:02:20 +0200 Subject: get_user_status: expose lat/lon from database view, do not re-compute it --- lib/Travelynx.pm | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 4d11fe1..1b81f88 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1421,12 +1421,16 @@ sub startup { dep_ds100 => $in_transit->{dep_ds100}, dep_eva => $in_transit->{dep_eva}, dep_name => $in_transit->{dep_name}, + dep_lat => $in_transit->{dep_lat}, + dep_lon => $in_transit->{dep_lon}, dep_platform => $in_transit->{dep_platform}, sched_arrival => epoch_to_dt( $in_transit->{sched_arr_ts} ), real_arrival => epoch_to_dt( $in_transit->{real_arr_ts} ), arr_ds100 => $in_transit->{arr_ds100}, arr_eva => $in_transit->{arr_eva}, arr_name => $in_transit->{arr_name}, + arr_lat => $in_transit->{arr_lat}, + arr_lon => $in_transit->{arr_lon}, arr_platform => $in_transit->{arr_platform}, route_after => \@route_after, messages => $in_transit->{messages}, @@ -1654,12 +1658,16 @@ sub startup { dep_ds100 => $latest->{dep_ds100}, dep_eva => $latest->{dep_eva}, dep_name => $latest->{dep_name}, + dep_lat => $latest->{dep_lat}, + dep_lon => $latest->{dep_lon}, dep_platform => $latest->{dep_platform}, sched_arrival => epoch_to_dt( $latest->{sched_arr_ts} ), real_arrival => epoch_to_dt( $latest->{real_arr_ts} ), arr_ds100 => $latest->{arr_ds100}, arr_eva => $latest->{arr_eva}, arr_name => $latest->{arr_name}, + arr_lat => $latest->{arr_lat}, + arr_lon => $latest->{arr_lon}, arr_platform => $latest->{arr_platform}, comment => $latest->{user_data}{comment}, visibility => $latest->{visibility}, @@ -1695,8 +1703,8 @@ sub startup { ds100 => $status->{dep_ds100}, name => $status->{dep_name}, uic => $status->{dep_eva}, - longitude => undef, - latitude => undef, + longitude => $status->{dep_lon}, + latitude => $status->{dep_lat}, scheduledTime => $status->{sched_departure} ? $status->{sched_departure}->epoch : undef, @@ -1708,8 +1716,8 @@ sub startup { ds100 => $status->{arr_ds100}, name => $status->{arr_name}, uic => $status->{arr_eva}, - longitude => undef, - latitude => undef, + longitude => $status->{arr_lon}, + latitude => $status->{arr_lat}, scheduledTime => $status->{sched_arrival} ? $status->{sched_arrival}->epoch : undef, @@ -1754,22 +1762,6 @@ sub startup { ); } - if ( $status->{dep_eva} ) { - if ( my $s = $self->stations->get_by_eva( $status->{dep_eva} ) ) - { - $ret->{fromStation}{longitude} = $s->{lon}; - $ret->{fromStation}{latitude} = $s->{lat}; - } - } - - if ( $status->{arr_eva} ) { - if ( my $s = $self->stations->get_by_eva( $status->{arr_eva} ) ) - { - $ret->{toStation}{longitude} = $s->{lon}; - $ret->{toStation}{latitude} = $s->{lat}; - } - } - return $ret; } ); -- cgit v1.2.3