perform stationinfo requests for hafas checkins

This commit is contained in:
Birte Kristina Friesel 2024-05-30 11:25:52 +02:00
parent 85c7861bc1
commit 2576a463db
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
2 changed files with 27 additions and 3 deletions

View file

@ -508,6 +508,8 @@ sub startup {
$self->add_route_timestamps( $uid, $train, 1 ); $self->add_route_timestamps( $uid, $train, 1 );
$self->add_wagonorder( $uid, 1, $train->train_id, $self->add_wagonorder( $uid, 1, $train->train_id,
$train->sched_departure, $train->train_no ); $train->sched_departure, $train->train_no );
$self->add_stationinfo( $uid, 1, $train->train_id,
$eva );
$self->run_hook( $uid, 'checkin' ); $self->run_hook( $uid, 'checkin' );
} }
@ -636,6 +638,8 @@ sub startup {
if ( $journey->class <= 16 ) { if ( $journey->class <= 16 ) {
$self->app->add_wagonorder( $uid, 1, $journey->id, $self->app->add_wagonorder( $uid, 1, $journey->id,
$found->sched_dep, $journey->number ); $found->sched_dep, $journey->number );
$self->add_stationinfo( $uid, 1, $journey->id,
$found->loc->eva );
} }
} }
@ -1000,6 +1004,8 @@ sub startup {
$self->add_route_timestamps( $uid, $train, 0, 1 ); $self->add_route_timestamps( $uid, $train, 0, 1 );
$self->add_wagonorder( $uid, 0, $train->train_id, $self->add_wagonorder( $uid, 0, $train->train_id,
$train->sched_departure, $train->train_no ); $train->sched_departure, $train->train_no );
$self->add_stationinfo( $uid, 0, $train->train_id,
$dep_eva, $new_checkout_station_id );
} }
$promise->resolve( 1, undef ); $promise->resolve( 1, undef );
return; return;
@ -1477,9 +1483,19 @@ sub startup {
return; return;
} }
)->wait; )->wait;
}
);
$self->helper(
'add_stationinfo' => sub {
my ( $self, $uid, $is_departure, $train_id, $dep_eva, $arr_eva )
= @_;
$uid //= $self->current_user->{id};
my $db = $self->pg->db;
if ($is_departure) { if ($is_departure) {
$self->dbdb->get_stationinfo_p( $in_transit->{dep_eva} )->then( $self->dbdb->get_stationinfo_p($dep_eva)->then(
sub { sub {
my ($station_info) = @_; my ($station_info) = @_;
my $data = { stationinfo_dep => $station_info }; my $data = { stationinfo_dep => $station_info };
@ -1500,8 +1516,8 @@ sub startup {
)->wait; )->wait;
} }
if ( $in_transit->{arr_eva} and not $is_departure ) { if ( $arr_eva and not $is_departure ) {
$self->dbdb->get_stationinfo_p( $in_transit->{arr_eva} )->then( $self->dbdb->get_stationinfo_p($arr_eva)->then(
sub { sub {
my ($station_info) = @_; my ($station_info) = @_;
my $data = { stationinfo_arr => $station_info }; my $data = { stationinfo_arr => $station_info };

View file

@ -73,6 +73,8 @@ sub run {
{ {
$self->app->add_wagonorder( $uid, 1, $train_id, $self->app->add_wagonorder( $uid, 1, $train_id,
$found_dep->sched_dep, $journey->number ); $found_dep->sched_dep, $journey->number );
$self->app->add_stationinfo( $uid, 1, $journey->id,
$found_dep->loc->eva );
} }
} }
@ -89,6 +91,8 @@ sub run {
{ {
$self->app->add_wagonorder( $uid, 0, $train_id, $self->app->add_wagonorder( $uid, 0, $train_id,
$found_dep->sched_dep, $journey->number ); $found_dep->sched_dep, $journey->number );
$self->app->add_stationinfo( $uid, 0, $journey->id,
$found_dep->loc->eva, $found_arr->loc->eva );
} }
} }
} }
@ -185,6 +189,8 @@ sub run {
$self->app->add_route_timestamps( $uid, $train, 1 ); $self->app->add_route_timestamps( $uid, $train, 1 );
$self->app->add_wagonorder( $uid, 1, $train->train_id, $self->app->add_wagonorder( $uid, 1, $train->train_id,
$train->sched_departure, $train->train_no ); $train->sched_departure, $train->train_no );
$self->app->add_stationinfo( $uid, 1, $train->train_id,
$dep, $arr );
} }
} }
}; };
@ -259,6 +265,8 @@ sub run {
); );
$self->app->add_wagonorder( $uid, 0, $train->train_id, $self->app->add_wagonorder( $uid, 0, $train->train_id,
$train->sched_departure, $train->train_no ); $train->sched_departure, $train->train_no );
$self->app->add_stationinfo( $uid, 0, $train->train_id,
$dep, $arr );
} }
} }
elsif ( $entry->{real_arr_ts} ) { elsif ( $entry->{real_arr_ts} ) {