Skip to content
Snippets Groups Projects
Verified Commit c97fd655 authored by Damien's avatar Damien
Browse files

FEAT #11907 TIME 1:00 Get priority with process limit date

parent 5495f6a8
No related branches found
No related tags found
No related merge requests found
...@@ -232,6 +232,7 @@ $app->get('/indexing/{groupId}/actions', \Resource\controllers\IndexingControlle ...@@ -232,6 +232,7 @@ $app->get('/indexing/{groupId}/actions', \Resource\controllers\IndexingControlle
$app->get('/indexing/{groupId}/entities', \Resource\controllers\IndexingController::class . ':getIndexingEntities'); $app->get('/indexing/{groupId}/entities', \Resource\controllers\IndexingController::class . ':getIndexingEntities');
$app->get('/indexing/processLimitDate', \Resource\controllers\IndexingController::class . ':getProcessLimitDate'); $app->get('/indexing/processLimitDate', \Resource\controllers\IndexingController::class . ':getProcessLimitDate');
$app->get('/indexing/fileInformations', \Resource\controllers\IndexingController::class . ':getFileInformations'); $app->get('/indexing/fileInformations', \Resource\controllers\IndexingController::class . ':getFileInformations');
$app->get('/indexing/priority', \Resource\controllers\IndexingController::class . ':getPriorityWithProcessLimitDate');
//IndexingModels //IndexingModels
$app->get('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':get'); $app->get('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':get');
......
...@@ -139,7 +139,7 @@ class IndexingController ...@@ -139,7 +139,7 @@ class IndexingController
$priority = PriorityModel::getById(['id' => $queryParams['priority'], 'select' => ['delays']]); $priority = PriorityModel::getById(['id' => $queryParams['priority'], 'select' => ['delays']]);
$delay = $priority['delays']; $delay = $priority['delays'];
} }
if (!Validator::intVal()->validate($delay)) { if (!isset($delay) || !Validator::intVal()->validate($delay)) {
return $response->withStatus(400)->withJson(['errors' => 'Delay is not a numeric value']); return $response->withStatus(400)->withJson(['errors' => 'Delay is not a numeric value']);
} }
...@@ -165,6 +165,28 @@ class IndexingController ...@@ -165,6 +165,28 @@ class IndexingController
return $response->withJson(['informations' => ['maximumSize' => $maximumSize, 'maximumSizeLabel' => $maximumSizeLabel, 'allowedFiles' => $allowedFiles]]); return $response->withJson(['informations' => ['maximumSize' => $maximumSize, 'maximumSizeLabel' => $maximumSizeLabel, 'allowedFiles' => $allowedFiles]]);
} }
public function getPriorityWithProcessLimitDate(Request $request, Response $response)
{
$queryParams = $request->getQueryParams();
if (empty($queryParams['processLimitDate'])) {
return $response->withStatus(400)->withJson(['errors' => 'Query params processLimitDate is empty']);
}
$processLimitDate = new \DateTime($queryParams['processLimitDate']);
$now = new \DateTime();
$diff = $processLimitDate->diff($now);
$diff = $diff->format("%a");
$priority = PriorityModel::get(['select' => ['id'], 'where' => ['delays > ?'], 'data' => [$diff], 'orderBy' => ['delays'], 'limit' => 1]);
if (empty($priority)) {
$priority = PriorityModel::get(['select' => ['id'], 'orderBy' => ['delays DESC'], 'limit' => 1]);
}
return $response->withJson(['priority' => $priority[0]['id']]);
}
public static function getEntitiesChildrenLevel($aArgs = []) public static function getEntitiesChildrenLevel($aArgs = [])
{ {
$entities = EntityModel::getEntityChildrenSubLevel([ $entities = EntityModel::getEntityChildrenSubLevel([
......
This diff is collapsed.
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