summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Helper/HAFAS.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-16 20:05:13 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-16 20:05:13 +0200
commit4411548d79bd507d3b97c929dfec94fc38fd4bf8 (patch)
treeb4c540d740023d8b9e4e3f20fea34c45e44a934f /lib/DBInfoscreen/Helper/HAFAS.pm
parenta6ab8b65ef9e028ce8418e0ff6c1a7f52572e1a0 (diff)
perform traininfo requests concurrently3.1.8
Diffstat (limited to 'lib/DBInfoscreen/Helper/HAFAS.pm')
-rw-r--r--lib/DBInfoscreen/Helper/HAFAS.pm24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm
index 0206bed..3b55051 100644
--- a/lib/DBInfoscreen/Helper/HAFAS.pm
+++ b/lib/DBInfoscreen/Helper/HAFAS.pm
@@ -255,28 +255,32 @@ sub get_route_timestamps_p {
}
my $base = 'https://reiseauskunft.bahn.de/bin/traininfo.exe/dn';
- my ( $trainsearch_result, $trainlink, $traininfo );
+ my ( $trainsearch_result, $trainlink );
$self->trainsearch_p(%opt)->then(
sub {
($trainsearch_result) = @_;
$trainlink = $trainsearch_result->{trainLink};
- return $self->get_json_p( $self->{realtime_cache},
- "${base}/${trainlink}?rt=1&date=$opt{date_yy}&L=vs_json" );
+ return Mojo::Promise->all(
+ $self->get_json_p(
+ $self->{realtime_cache},
+ "${base}/${trainlink}?rt=1&date=$opt{date_yy}&L=vs_json"
+ ),
+ $self->get_xml_p(
+ $self->{realtime_cache},
+ "${base}/${trainlink}?rt=1&date=$opt{date_yy}&L=vs_java3"
+ )
+ );
}
)->then(
sub {
- ($traininfo) = @_;
+ my ( $traininfo, $traindelay ) = @_;
+ $traininfo = $traininfo->[0];
+ $traindelay = $traindelay->[0];
if ( not $traininfo or $traininfo->{error} ) {
$promise->reject;
return;
}
- return $self->get_xml_p( $self->{realtime_cache},
- "${base}/${trainlink}?rt=1&date=$opt{date_yy}&L=vs_java3" );
- }
- )->then(
- sub {
- my ($traindelay) = @_;
my $ret = {};
my $strp = DateTime::Format::Strptime->new(