diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index 29479021..3408bf0c 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -29,11 +29,11 @@ public function clipOverlappingPolygonsBySite(string $uuid) $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $site->id, 'entity_type' => get_class($site), 'entity_name' => $site->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Fix', ]); @@ -89,11 +89,11 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $site->id, 'entity_type' => get_class($site), 'entity_name' => $site->name, - ]), + ], 'created_by' => $user->id, 'is_acknowledged' => false, 'name' => 'Polygon Fix', @@ -152,11 +152,11 @@ public function clipOverlappingPolygons(Request $request) $user = Auth::user(); $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'created_by' => $user->id, 'is_acknowledged' => false, 'name' => 'Polygon Fix', diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 2a32b3e2..a3b4bf6d 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -242,11 +242,11 @@ function ($attribute, $value, $fail) { Redis::set($redis_key, $geojsonContent, 'EX', 7200); $delayedJob = DelayedJob::create([ 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Upload', ]); @@ -413,11 +413,11 @@ public function uploadShapefile(Request $request) Redis::set($redis_key, $geojsonContent, 'EX', 7200); $delayedJob = DelayedJob::create([ 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Upload', ]); @@ -644,11 +644,11 @@ public function uploadGeoJSONFile(Request $request) Redis::set($redis_key, $geojson_content, 'EX', 7200); $delayedJob = DelayedJob::create([ 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Upload', ]); @@ -1260,11 +1260,11 @@ public function runSiteValidationPolygon(Request $request) 'total_content' => count($sitePolygonsUuids), 'processed_content' => 0, 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Validation', ]); @@ -1293,11 +1293,11 @@ public function runPolygonsValidation(Request $request) 'total_content' => count($uuids), 'processed_content' => 0, 'created_by' => $user->id, - 'metadata' => json_encode([ + 'metadata' => [ 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'entity_name' => $entity->name, - ]), + ], 'is_acknowledged' => false, 'name' => 'Polygon Validation', ]); diff --git a/app/Jobs/FixPolygonOverlapJob.php b/app/Jobs/FixPolygonOverlapJob.php index 61c66192..ab1e2f23 100644 --- a/app/Jobs/FixPolygonOverlapJob.php +++ b/app/Jobs/FixPolygonOverlapJob.php @@ -69,7 +69,7 @@ public function handle(): void try { $delayedJob = DelayedJobProgress::findOrFail($this->delayed_job_id); $user = Auth::user(); - $metadata = json_decode($delayedJob->metadata, true); + $metadata = $delayedJob->metadata; $entityId = $metadata['entity_id'] ?? null; $site = Site::findOrFail($entityId); $userForMail = $delayedJob->creator; diff --git a/app/Jobs/InsertGeojsonToDBJob.php b/app/Jobs/InsertGeojsonToDBJob.php index a17747d9..8809163e 100755 --- a/app/Jobs/InsertGeojsonToDBJob.php +++ b/app/Jobs/InsertGeojsonToDBJob.php @@ -55,7 +55,7 @@ public function handle(PolygonService $service) { $delayedJob = DelayedJob::findOrFail($this->delayed_job_id); $user = $delayedJob->creator; - $metadata = json_decode($delayedJob->metadata, true); + $metadata = $delayedJob->metadata; $entityId = $metadata['entity_id'] ?? null; $site = Site::findOrFail($entityId); diff --git a/app/Jobs/RunSitePolygonsValidationJob.php b/app/Jobs/RunSitePolygonsValidationJob.php index edf8c0c9..bcd1b43a 100644 --- a/app/Jobs/RunSitePolygonsValidationJob.php +++ b/app/Jobs/RunSitePolygonsValidationJob.php @@ -54,10 +54,15 @@ public function handle(PolygonValidationService $validationService) try { $delayedJob = DelayedJobProgress::findOrFail($this->delayed_job_id); $user = $delayedJob->creator; - $metadata = json_decode($delayedJob->metadata, true); + $metadata = $delayedJob->metadata; + $entityId = $metadata['entity_id'] ?? null; - $site = Site::findOrFail($entityId); + if ($entityId) { + $site = Site::findOrFail($entityId); + } else { + Log::error('entityId is null, unable to find site'); + } if (! $site) { throw new Exception('Site not found for the given site UUID.'); diff --git a/app/Models/DelayedJob.php b/app/Models/DelayedJob.php index b0614794..ca69dbfd 100644 --- a/app/Models/DelayedJob.php +++ b/app/Models/DelayedJob.php @@ -22,6 +22,7 @@ class DelayedJob extends Model protected $casts = [ 'uuid' => 'string', + 'metadata' => 'array', ]; public function creator()