summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model/Stations.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Model/Stations.pm')
-rw-r--r--lib/Travelynx/Model/Stations.pm19
1 files changed, 10 insertions, 9 deletions
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
}