Scheduling UI corrected

This commit is contained in:
2022-11-30 20:45:18 -03:00
parent 5e4e52e620
commit c0ddd00cc6
4 changed files with 115 additions and 200 deletions

View File

@ -12,7 +12,7 @@ class Jobs
{
use Json;
public function schedule(ServerRequestInterface $request, ResponseInterface $response, Service $jobsService): ResponseInterface
public function schedule(ServerRequestInterface $request, ResponseInterface $response, Service $service, \ProVM\Common\Service\Messages $messagesService): ResponseInterface
{
$body = $request->getBody();
$json = \Safe\json_decode($body->getContents());
@ -25,21 +25,24 @@ class Jobs
'scheduled' => 0
];
foreach ($json->messages as $message_id) {
if ($jobsService->schedule($message_id)) {
if ($service->schedule($message_id)) {
$message = $messagesService->getRepository()->fetchById($message_id);
$message->doesHaveScheduledDownloads();
$messagesService->getRepository()->save($message);
$output['scheduled'] ++;
}
}
return $this->withJson($response, $output);
}
public function pending(ServerRequestInterface $request, ResponseInterface $response, Service $jobsService): ResponseInterface
public function pending(ServerRequestInterface $request, ResponseInterface $response, Service $service): ResponseInterface
{
$pending = array_map(function(Job $job) {
return $job->toArray();
}, $jobsService->getPending());
}, $service->getPending());
$output = [
'total' => count($pending),
'pending' => $pending
];
return $this->withJson($response, $output);
}
}
}