summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller/Traveling.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-01-08 18:11:28 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-01-08 18:11:28 +0100
commit42f9a00d98dbd675234c05b3e25c3e722cfdd7ba (patch)
treecc27bb0a0746c19829d607e14e6cd39537997ad4 /lib/Travelynx/Controller/Traveling.pm
parent35660567614dea8d4572bcfe5bb1890504be0c20 (diff)
EFA support (WiP)efa-support
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index f61d83d..53d28a9 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -917,6 +917,8 @@ sub station {
$timestamp = DateTime->now( time_zone => 'Europe/Berlin' );
}
+ my $efa_service = $self->param('efa')
+ // ( $user->{backend_efa} ? $user->{backend_name} : undef );
my $hafas_service = $self->param('hafas')
// ( $user->{backend_hafas} ? $user->{backend_name} : undef );
my $promise;
@@ -929,6 +931,15 @@ sub station {
lookahead => 30,
);
}
+ elsif ($efa_service) {
+ $promise = $self->efa->get_departures_p(
+ service => $efa_service,
+ name => $station,
+ timestamp => $timestamp,
+ lookbehind => 10,
+ lookahead => 30,
+ );
+ }
else {
$promise = $self->iris->get_departures_p(
station => $station,
@@ -967,6 +978,16 @@ sub station {
related_stations => [],
};
}
+ elsif ($efa_service) {
+ @results = map { $_->[0] }
+ sort { $b->[1] <=> $a->[1] }
+ map { [ $_, $_->datetime->epoch ] } $status->results;
+ $status = {
+ station_eva => $status->stop->id,
+ station_name => $status->stop->full_name,
+ related_stations => [],
+ };
+ }
else {
# You can't check into a train which terminates here
@@ -1013,12 +1034,14 @@ sub station {
eva => $user_status->{cancellation}{dep_eva},
destination_name =>
$user_status->{cancellation}{arr_name},
+ efa => $efa_service,
hafas => $hafas_service,
);
}
else {
$connections_p = $self->get_connecting_trains_p(
eva => $status->{station_eva},
+ efa => $efa_service,
hafas => $hafas_service
);
}
@@ -1031,6 +1054,7 @@ sub station {
$self->render(
'departures',
user => $user,
+ efa => $efa_service,
hafas => $hafas_service,
eva => $status->{station_eva},
datetime => $timestamp,
@@ -1050,6 +1074,7 @@ sub station {
$self->render(
'departures',
user => $user,
+ efa => $efa_service,
hafas => $hafas_service,
eva => $status->{station_eva},
datetime => $timestamp,
@@ -1068,6 +1093,7 @@ sub station {
$self->render(
'departures',
user => $user,
+ efa => $efa_service,
hafas => $hafas_service,
eva => $status->{station_eva},
datetime => $timestamp,