diff options
Diffstat (limited to 'lib/Travelynx/Model')
-rw-r--r-- | lib/Travelynx/Model/InTransit.pm | 38 | ||||
-rw-r--r-- | lib/Travelynx/Model/Stations.pm | 19 |
2 files changed, 29 insertions, 28 deletions
diff --git a/lib/Travelynx/Model/InTransit.pm b/lib/Travelynx/Model/InTransit.pm index adcdfa3..fa9c464 100644 --- a/lib/Travelynx/Model/InTransit.pm +++ b/lib/Travelynx/Model/InTransit.pm @@ -126,16 +126,16 @@ sub add { push( @route, [ - $j_stop->name, - $j_stop->eva, + $j_stop->loc->name, + $j_stop->loc->eva, { - sched_arr => _epoch( $j_stop->{sched_arr} ), - sched_dep => _epoch( $j_stop->{sched_dep} ), - rt_arr => _epoch( $j_stop->{rt_arr} ), - rt_dep => _epoch( $j_stop->{rt_dep} ), - arr_delay => $j_stop->{arr_delay}, - dep_delay => $j_stop->{dep_delay}, - load => $j_stop->{load} + sched_arr => _epoch( $j_stop->sched_arr ), + sched_dep => _epoch( $j_stop->sched_dep ), + rt_arr => _epoch( $j_stop->rt_arr ), + rt_dep => _epoch( $j_stop->rt_dep ), + arr_delay => $j_stop->arr_delay, + dep_delay => $j_stop->dep_delay, + load => $j_stop->load } ] ); @@ -147,7 +147,7 @@ sub add { cancelled => $stop->{dep_cancelled} ? 1 : 0, - checkin_station_id => $stop->eva, + checkin_station_id => $stop->loc->eva, checkin_time => DateTime->now( time_zone => 'Europe/Berlin' ), dep_platform => $stop->{platform}, train_type => $journey->type // q{}, @@ -724,16 +724,16 @@ sub update_arrival_hafas { push( @route, [ - $j_stop->name, - $j_stop->eva, + $j_stop->loc->name, + $j_stop->loc->eva, { - sched_arr => _epoch( $j_stop->{sched_arr} ), - sched_dep => _epoch( $j_stop->{sched_dep} ), - rt_arr => _epoch( $j_stop->{rt_arr} ), - rt_dep => _epoch( $j_stop->{rt_dep} ), - arr_delay => $j_stop->{arr_delay}, - dep_delay => $j_stop->{dep_delay}, - load => $j_stop->{load} + sched_arr => _epoch( $j_stop->sched_arr ), + sched_dep => _epoch( $j_stop->sched_dep ), + rt_arr => _epoch( $j_stop->rt_arr ), + rt_dep => _epoch( $j_stop->rt_dep ), + arr_delay => $j_stop->arr_delay, + dep_delay => $j_stop->dep_delay, + load => $j_stop->load } ] ); diff --git a/lib/Travelynx/Model/Stations.pm b/lib/Travelynx/Model/Stations.pm index 147219f..5bbe781 100644 --- a/lib/Travelynx/Model/Stations.pm +++ b/lib/Travelynx/Model/Stations.pm @@ -17,33 +17,34 @@ sub new { sub add_or_update { my ( $self, %opt ) = @_; my $stop = $opt{stop}; + my $loc = $stop->loc; my $source = 1; my $db = $opt{db} // $self->{pg}->db; - if ( my $s = $self->get_by_eva( $stop->eva, db => $db ) ) { + if ( my $s = $self->get_by_eva( $loc->eva, db => $db ) ) { if ( $source == 1 and $s->{source} == 0 and not $s->{archived} ) { return; } $db->update( 'stations', { - name => $stop->name, - lat => $stop->lat, - lon => $stop->lon, + name => $loc->name, + lat => $loc->lat, + lon => $loc->lon, source => $source, archived => 0 }, - { eva => $stop->eva } + { eva => $loc->eva } ); return; } $db->insert( 'stations', { - eva => $stop->eva, - name => $stop->name, - lat => $stop->lat, - lon => $stop->lon, + eva => $loc->eva, + name => $loc->name, + lat => $loc->lat, + lon => $loc->lon, source => $source, archived => 0 } |