Jobs not being updated

This commit is contained in:
Juan Pablo Vial
2025-05-13 16:06:09 -04:00
parent d536342425
commit 024a6eae54
2 changed files with 20 additions and 1 deletions

View File

@ -5,7 +5,7 @@ use PDOException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal; use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception\EmptyResult; use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Exception\ServiceAction\{Create,Read}; use Incoviba\Exception\ServiceAction\{Create, Read, Update};
use Incoviba\Repository; use Incoviba\Repository;
use Incoviba\Model; use Incoviba\Model;
@ -44,6 +44,21 @@ class Job extends Ideal\Service
} }
} }
/**
* @param Model\Job $job
* @return bool
* @throws Update
*/
public function execute(Model\Job $job): bool
{
try {
$this->jobRepository->edit($job, ['executed' => true]);
return true;
} catch (EmptyResult | PDOException $exception) {
throw new Update(__CLASS__, $exception);
}
}
protected function process(Model\Job $job): Model\Job protected function process(Model\Job $job): Model\Job
{ {
return $job; return $job;

View File

@ -59,6 +59,10 @@ class Queue extends Ideal\Service
try { try {
if (!$worker->execute($job)) { if (!$worker->execute($job)) {
$errors []= $job->id; $errors []= $job->id;
} else {
if (!$this->jobService->execute($job)) {
$errors []= $job->id;
}
} }
} catch (Exception $exception) { } catch (Exception $exception) {
$final = new Exception("Could not run job", 0, $exception); $final = new Exception("Could not run job", 0, $exception);