Skip to content
Snippets Groups Projects
Commit a15e7f4f authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #12091 TIME 2:00 prevent placing user before processed users

parent 70cc8de2
No related branches found
No related tags found
No related merge requests found
......@@ -356,14 +356,23 @@ class ListInstanceController
'where' => ['res_id = ?', 'difflist_type = ?'],
'data' => [$resource['resId'], self::MAPPING_TYPES[$args['type']]]
]);
$newListSequenceOrdered = array_column($resource['listInstances'], null, 'sequence');
ListInstanceModel::delete([
'where' => ['res_id = ?', 'difflist_type = ?'],
'data' => [$resource['resId'], self::MAPPING_TYPES[$args['type']]]
]);
$minSequenceNoProcessDate = -1;
foreach ($listInstances as $listInstanceKey => $listInstance) {
if (empty($listInstance['process_date'])) {
unset($listInstances[$listInstanceKey]);
} else {
if ($listInstance['sequence'] > $minSequenceNoProcessDate) {
$minSequenceNoProcessDate = $listInstance['sequence'];
}
}
}
$listInstances = array_values($listInstances);
......@@ -379,6 +388,11 @@ class ListInstanceController
return $response->withStatus(400)->withJson(['errors' => "Body resources[{$resourceKey}] listInstances[{$key}] process_comment is too long"]);
}
if ($listInstance['sequence'] <= $minSequenceNoProcessDate) {
DatabaseModel::rollbackTransaction();
return $response->withStatus(400)->withJson(['errors' => "Body resources[{$resourceKey}] listInstances[{$key}] sequence is before already processed users"]);
}
if ($listInstance['item_type'] == 'user_id') {
$user = UserModel::getByLogin(['login' => $listInstance['item_id'], 'select' => ['id'], 'noDeleted' => true]);
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment