mirror of
https://github.com/derf/travelynx
synced 2024-11-10 06:54:17 +00:00
add_route_timestamps: do not re-request trip id if it is already known
This commit is contained in:
parent
c5af2fec5b
commit
43fc820e0c
1 changed files with 19 additions and 8 deletions
|
@ -1372,17 +1372,28 @@ sub startup {
|
||||||
my $route = $in_transit->{route};
|
my $route = $in_transit->{route};
|
||||||
my $train_id = $train->train_id;
|
my $train_id = $train->train_id;
|
||||||
|
|
||||||
# TODO get_tripid_p is only needed on the first call, afterwards the tripid is known.
|
my $tripid_promise;
|
||||||
$self->hafas->get_tripid_p( train => $train )->then(
|
|
||||||
|
if ( $in_transit->{data}{trip_id} ) {
|
||||||
|
$tripid_promise
|
||||||
|
= Mojo::Promise->resolve( $in_transit->{data}{trip_id} );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tripid_promise = $self->hafas->get_tripid_p( train => $train );
|
||||||
|
}
|
||||||
|
|
||||||
|
$tripid_promise->then(
|
||||||
sub {
|
sub {
|
||||||
my ($trip_id) = @_;
|
my ($trip_id) = @_;
|
||||||
|
|
||||||
$self->in_transit->update_data(
|
if ( not $in_transit->{extra_data}{trip_id} ) {
|
||||||
uid => $uid,
|
$self->in_transit->update_data(
|
||||||
db => $db,
|
uid => $uid,
|
||||||
data => { trip_id => $trip_id },
|
db => $db,
|
||||||
train_id => $train_id,
|
data => { trip_id => $trip_id },
|
||||||
);
|
train_id => $train_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $self->hafas->get_route_p(
|
return $self->hafas->get_route_p(
|
||||||
train => $train,
|
train => $train,
|
||||||
|
|
Loading…
Reference in a new issue