permanently store wagon numbers and types when available
This commit is contained in:
parent
e6160d75de
commit
b211e0842a
1 changed files with 43 additions and 10 deletions
|
@ -2146,24 +2146,57 @@ sub startup {
|
|||
sub {
|
||||
my ($wagonorder) = @_;
|
||||
|
||||
my $res = $db->select( 'in_transit', ['data'],
|
||||
{ user_id => $uid } );
|
||||
my $res = $db->select(
|
||||
'in_transit',
|
||||
[ 'data', 'user_data' ],
|
||||
{ user_id => $uid }
|
||||
);
|
||||
my $res_h = $res->expand->hash;
|
||||
my $data = $res_h->{data} // {};
|
||||
my $user_data = $res_h->{user_data} // {};
|
||||
|
||||
if ($is_departure) {
|
||||
$data->{wagonorder_dep} = $wagonorder;
|
||||
$user_data->{wagons} = [];
|
||||
for my $group (
|
||||
@{
|
||||
$wagonorder->{data}{istformation}
|
||||
{allFahrzeuggruppe} // []
|
||||
}
|
||||
)
|
||||
{
|
||||
for
|
||||
my $wagon ( @{ $group->{allFahrzeug} // [] } )
|
||||
{
|
||||
push(
|
||||
@{ $user_data->{wagons} },
|
||||
{
|
||||
id => $wagon->{fahrzeugnummer},
|
||||
number =>
|
||||
$wagon->{wagenordnungsnummer},
|
||||
type => $wagon->{fahrzeugtyp},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
$db->update(
|
||||
'in_transit',
|
||||
{
|
||||
data => JSON->new->encode($data),
|
||||
user_data => JSON->new->encode($user_data)
|
||||
},
|
||||
{ user_id => $uid }
|
||||
);
|
||||
}
|
||||
else {
|
||||
$data->{wagonorder_arr} = $wagonorder;
|
||||
}
|
||||
|
||||
$db->update(
|
||||
'in_transit',
|
||||
{ data => JSON->new->encode($data) },
|
||||
{ user_id => $uid }
|
||||
);
|
||||
}
|
||||
}
|
||||
)->wait;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue