InTransit: allow setting data in add call

This commit is contained in:
Birte Kristina Friesel 2024-06-15 22:03:36 +02:00
parent 7466d252fb
commit d7fd521899
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
2 changed files with 10 additions and 7 deletions

View file

@ -573,6 +573,7 @@ sub startup {
db => $db, db => $db,
journey => $journey, journey => $journey,
stop => $found, stop => $found,
data => { trip_id => $journey->id }
); );
}; };
if ($@) { if ($@) {
@ -581,11 +582,6 @@ sub startup {
$promise->reject( 'INSERT failed: ' . $@ ); $promise->reject( 'INSERT failed: ' . $@ );
return; return;
} }
$self->in_transit->update_data(
uid => $uid,
db => $db,
data => { trip_id => $journey->id }
);
my $polyline; my $polyline;
if ( $journey->polyline ) { if ( $journey->polyline ) {

View file

@ -98,6 +98,7 @@ sub add {
my $stop = $opt{stop}; my $stop = $opt{stop};
my $checkin_station_id = $opt{departure_eva}; my $checkin_station_id = $opt{departure_eva};
my $route = $opt{route}; my $route = $opt{route};
my $data = $opt{data};
my $json = JSON->new; my $json = JSON->new;
@ -126,7 +127,8 @@ sub add {
data => JSON->new->encode( data => JSON->new->encode(
{ {
rt => $train->departure_has_realtime ? 1 rt => $train->departure_has_realtime ? 1
: 0 : 0,
%{ $data // {} }
} }
), ),
backend_id => $backend_id, backend_id => $backend_id,
@ -183,7 +185,12 @@ sub add {
sched_departure => $stop->{sched_dep}, sched_departure => $stop->{sched_dep},
real_departure => $stop->{rt_dep} // $stop->{sched_dep}, real_departure => $stop->{rt_dep} // $stop->{sched_dep},
route => $json->encode( \@route ), route => $json->encode( \@route ),
data => JSON->new->encode( { rt => $stop->{rt_dep} ? 1 : 0 } ), data => JSON->new->encode(
{
rt => $stop->{rt_dep} ? 1 : 0,
%{ $data // {} }
}
),
backend_id => $backend_id, backend_id => $backend_id,
} }
); );