From 024a6eae540def620d9dab4f7c9e5c7256325416 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Tue, 13 May 2025 16:06:09 -0400 Subject: [PATCH] Jobs not being updated --- app/src/Service/Job.php | 17 ++++++++++++++++- app/src/Service/Queue.php | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/Service/Job.php b/app/src/Service/Job.php index a28b641..3b612ae 100644 --- a/app/src/Service/Job.php +++ b/app/src/Service/Job.php @@ -5,7 +5,7 @@ use PDOException; use Psr\Log\LoggerInterface; use Incoviba\Common\Ideal; use Incoviba\Common\Implement\Exception\EmptyResult; -use Incoviba\Exception\ServiceAction\{Create,Read}; +use Incoviba\Exception\ServiceAction\{Create, Read, Update}; use Incoviba\Repository; 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 { return $job; diff --git a/app/src/Service/Queue.php b/app/src/Service/Queue.php index 042ce39..f22f06b 100644 --- a/app/src/Service/Queue.php +++ b/app/src/Service/Queue.php @@ -59,6 +59,10 @@ class Queue extends Ideal\Service try { if (!$worker->execute($job)) { $errors []= $job->id; + } else { + if (!$this->jobService->execute($job)) { + $errors []= $job->id; + } } } catch (Exception $exception) { $final = new Exception("Could not run job", 0, $exception);