summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model/InTransit.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-06-08 22:18:31 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-06-08 22:18:31 +0200
commitf71348a8a8b7d76e135efb32d94a61b2bd15711f (patch)
tree46e2562cbb5dc869f45488c2781978967067a9e2 /lib/Travelynx/Model/InTransit.pm
parentc969424c2d27bd862354b29a43082ded885dc69f (diff)
Store journey backend; do not rely on '|' in ID to distinguish IRIS/HAFAS
This is in preparation for supporting multiple HAFAS backends, and possibly EFA and RIS::Journeys.
Diffstat (limited to 'lib/Travelynx/Model/InTransit.pm')
-rw-r--r--lib/Travelynx/Model/InTransit.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/InTransit.pm b/lib/Travelynx/Model/InTransit.pm
index 0d548c3..09f682f 100644
--- a/lib/Travelynx/Model/InTransit.pm
+++ b/lib/Travelynx/Model/InTransit.pm
@@ -102,6 +102,8 @@ sub add {
my $json = JSON->new;
if ($train) {
+ my $backend_id
+ = $db->select( 'backends', ['id'], { iris => 1 } )->hash->{id};
$db->insert(
'in_transit',
{
@@ -127,10 +129,19 @@ sub add {
: 0
}
),
+ backend_id => $backend_id,
}
);
}
elsif ( $journey and $stop ) {
+ my $backend_id = $db->select(
+ 'backends',
+ ['id'],
+ {
+ hafas => 1,
+ name => 'DB'
+ }
+ )->hash->{id};
my @route;
my $product = $journey->product_at( $stop->loc->eva )
// $journey->product;
@@ -173,6 +184,7 @@ sub add {
real_departure => $stop->{rt_dep} // $stop->{sched_dep},
route => $json->encode( \@route ),
data => JSON->new->encode( { rt => $stop->{rt_dep} ? 1 : 0 } ),
+ backend_id => $backend_id,
}
);
}