From 52cb4f0acbc7e25a46c389f4dec8466dddb36bfe Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 4 Dec 2024 12:19:53 -0400 Subject: [PATCH 01/19] [TM-1531] entity record and creator to delayedJOb --- .../TerrafundCreateGeometryController.php | 5 ++++ app/Jobs/FixPolygonOverlapJob.php | 2 +- app/Models/DelayedJob.php | 16 ++++++---- app/Models/Site.php | 4 +++ ...151101_add_entity_morph_and_created_by.php | 30 +++++++++++++++++++ 5 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index dab1bddbb..30c7c397d 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -1219,10 +1219,15 @@ public function runSiteValidationPolygon(Request $request) try { $uuid = $request->input('uuid'); + $user = Auth::user(); + $entity = Site::where('uuid', $uuid)->firstOrFail(); $sitePolygonsUuids = GeometryHelper::getSitePolygonsUuids($uuid)->toArray(); $delayedJob = DelayedJobProgress::create([ 'total_content' => count($sitePolygonsUuids), 'processed_content' => 0, + 'created_by' => $user->id, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity) ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); diff --git a/app/Jobs/FixPolygonOverlapJob.php b/app/Jobs/FixPolygonOverlapJob.php index a272f8693..3f610f852 100644 --- a/app/Jobs/FixPolygonOverlapJob.php +++ b/app/Jobs/FixPolygonOverlapJob.php @@ -84,7 +84,7 @@ public function handle(): void 'status_code' => Response::HTTP_INTERNAL_SERVER_ERROR, ]); } catch (Throwable $e) { - Log::error('Throwable Error in RunSitePolygonsValidationJob: ' . $e->getMessage()); + Log::error('Throwable Error in Fix overlap job: ' . $e->getMessage()); DelayedJob::where('uuid', $this->delayed_job_id)->update([ 'status' => DelayedJob::STATUS_FAILED, diff --git a/app/Models/DelayedJob.php b/app/Models/DelayedJob.php index 4ae833449..4cc7840bf 100644 --- a/app/Models/DelayedJob.php +++ b/app/Models/DelayedJob.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Models\Traits\HasUuid; +use App\Models\V2\User; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -17,14 +18,17 @@ class DelayedJob extends Model protected $table = 'delayed_jobs'; - protected $fillable = [ - 'uuid', - 'status', - 'status_code', - 'payload', - ]; + protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by']; protected $casts = [ 'uuid' => 'string', ]; + public function entity() + { + return $this->morphTo(); + } + public function creator() + { + return $this->belongsTo(User::class, 'created_by'); + } } diff --git a/app/Models/Site.php b/app/Models/Site.php index b50b01d87..3baba134a 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -156,4 +156,8 @@ public function getTotalWorkdaysAttribute(): int { return $this->total_paid_workdays + $this->total_volunteer_workdays; } + public function delayedJobs() + { + return $this->morphMany(DelayedJob::class, 'entity'); + } } diff --git a/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php new file mode 100644 index 000000000..a613e97a3 --- /dev/null +++ b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php @@ -0,0 +1,30 @@ +nullableMorphs('entity'); + $table->string('created_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('delayed_jobs', function (Blueprint $table) { + $table->dropMorphs('entity'); + $table->dropColumn('created_by'); + }); + } +}; From 218ec97f82bf5cc426f0cf1182a54fc83e77ea99 Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 4 Dec 2024 12:30:23 -0400 Subject: [PATCH 02/19] [TM-1531] add useer to endpoint --- .../V2/Terrafund/TerrafundCreateGeometryController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 30c7c397d..f51ee5223 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -1244,9 +1244,11 @@ public function runPolygonsValidation(Request $request) { try { $uuids = $request->input('uuids'); + $user = Auth::user(); $delayedJob = DelayedJobProgress::create([ 'total_content' => count($uuids), 'processed_content' => 0, + 'created_by' => $user->id, ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); From e966b5775de65dba6d32ac277d3a4f32c8cc26f1 Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 4 Dec 2024 14:45:21 -0400 Subject: [PATCH 03/19] [TM-1531] add entity data for polygons validations --- .../V2/Terrafund/TerrafundCreateGeometryController.php | 9 ++++++++- app/Models/DelayedJob.php | 2 ++ app/Models/Site.php | 1 + .../Terrafund/post-v2-terrafund-validation-polygons.yml | 4 ++++ resources/docs/swagger-v2.yml | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index f51ee5223..047dcbc3a 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -1227,7 +1227,7 @@ public function runSiteValidationPolygon(Request $request) 'processed_content' => 0, 'created_by' => $user->id, 'entity_id' => $entity->id, - 'entity_type' => get_class($entity) + 'entity_type' => get_class($entity), ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1244,11 +1244,18 @@ public function runPolygonsValidation(Request $request) { try { $uuids = $request->input('uuids'); + $uuid = $request->input('entity_uuid'); + $type = $request->input('entity_type'); + if ($type === 'sites') { + $entity = Site::where('uuid', $uuid)->firstOrFail(); + } $user = Auth::user(); $delayedJob = DelayedJobProgress::create([ 'total_content' => count($uuids), 'processed_content' => 0, 'created_by' => $user->id, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity), ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); diff --git a/app/Models/DelayedJob.php b/app/Models/DelayedJob.php index 4cc7840bf..95ee0a576 100644 --- a/app/Models/DelayedJob.php +++ b/app/Models/DelayedJob.php @@ -23,10 +23,12 @@ class DelayedJob extends Model protected $casts = [ 'uuid' => 'string', ]; + public function entity() { return $this->morphTo(); } + public function creator() { return $this->belongsTo(User::class, 'created_by'); diff --git a/app/Models/Site.php b/app/Models/Site.php index 3baba134a..12d4ef4ef 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -156,6 +156,7 @@ public function getTotalWorkdaysAttribute(): int { return $this->total_paid_workdays + $this->total_volunteer_workdays; } + public function delayedJobs() { return $this->morphMany(DelayedJob::class, 'entity'); diff --git a/openapi-src/V2/paths/Terrafund/post-v2-terrafund-validation-polygons.yml b/openapi-src/V2/paths/Terrafund/post-v2-terrafund-validation-polygons.yml index c63331051..f4582f40f 100644 --- a/openapi-src/V2/paths/Terrafund/post-v2-terrafund-validation-polygons.yml +++ b/openapi-src/V2/paths/Terrafund/post-v2-terrafund-validation-polygons.yml @@ -11,6 +11,10 @@ parameters: items: type: string description: UUIDs of the polygon geometries to be validated + entity_uuid: + type: string + entity_type: + type: string responses: '200': description: Successful response diff --git a/resources/docs/swagger-v2.yml b/resources/docs/swagger-v2.yml index 6ffff9c2a..18b175d0b 100644 --- a/resources/docs/swagger-v2.yml +++ b/resources/docs/swagger-v2.yml @@ -99220,6 +99220,10 @@ paths: items: type: string description: UUIDs of the polygon geometries to be validated + entity_uuid: + type: string + entity_type: + type: string responses: '200': description: Successful response From 455508ff0d763baaa92f739eeeb86cf2dc639e12 Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 4 Dec 2024 14:48:22 -0400 Subject: [PATCH 04/19] [TM-1531] lint --- ...4_12_04_151101_add_entity_morph_and_created_by.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php index a613e97a3..938e8626f 100644 --- a/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php +++ b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php @@ -4,16 +4,15 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('delayed_jobs', function (Blueprint $table) { - $table->nullableMorphs('entity'); - $table->string('created_by')->nullable(); + $table->nullableMorphs('entity'); + $table->string('created_by')->nullable(); }); } @@ -23,8 +22,8 @@ public function up(): void public function down(): void { Schema::table('delayed_jobs', function (Blueprint $table) { - $table->dropMorphs('entity'); - $table->dropColumn('created_by'); + $table->dropMorphs('entity'); + $table->dropColumn('created_by'); }); } }; From 2f53855d46bd7e497130e1a588059dd5a9189329 Mon Sep 17 00:00:00 2001 From: JORGE Date: Thu, 5 Dec 2024 09:53:45 -0400 Subject: [PATCH 05/19] [TM-1531] add is_cleared --- .../Terrafund/TerrafundClipGeometryController.php | 15 +++++++++++++++ ..._04_151101_add_entity_morph_and_created_by.php | 2 ++ .../post-v2-terrafund-clip-polygons-polygons.yml | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index 67d92f8fe..f56dded8e 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -24,9 +24,13 @@ public function clipOverlappingPolygonsBySite(string $uuid) ini_set('max_execution_time', self::MAX_EXECUTION_TIME); ini_set('memory_limit', '-1'); $user = Auth::user(); + $site = Site::isUuid($uuid)->first(); $polygonUuids = GeometryHelper::getSitePolygonsUuids($uuid)->toArray(); $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, + 'created_by' => $user->id, + 'entity_id' => $site->id, + 'entity_type' => get_class($site), ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); @@ -80,6 +84,9 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, + 'entity_id' => $sitePolygon->id, + 'entity_type' => get_class($sitePolygon), + 'created_by' => $user->id ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); @@ -92,6 +99,11 @@ public function clipOverlappingPolygons(Request $request) ini_set('max_execution_time', self::MAX_EXECUTION_TIME); ini_set('memory_limit', '-1'); $uuids = $request->input('uuids'); + $uuid = $request->input('entity_uuid'); + $type = $request->input('entity_type'); + if ($type === 'sites') { + $entity = Site::where('uuid', $uuid)->firstOrFail(); + } Log::info('Clipping polygons', ['uuids' => $uuids]); if (empty($uuids) || ! is_array($uuids)) { return response()->json(['error' => 'Invalid or missing UUIDs'], 400); @@ -130,6 +142,9 @@ public function clipOverlappingPolygons(Request $request) $user = Auth::user(); $delayedJob = DelayedJobProgress::create([ 'processed_content' => 0, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity), + 'created_by' => $user->id ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); diff --git a/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php index 938e8626f..af98d3991 100644 --- a/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php +++ b/database/migrations/2024_12_04_151101_add_entity_morph_and_created_by.php @@ -13,6 +13,7 @@ public function up(): void Schema::table('delayed_jobs', function (Blueprint $table) { $table->nullableMorphs('entity'); $table->string('created_by')->nullable(); + $table->boolean('is_cleared')->default(false); }); } @@ -24,6 +25,7 @@ public function down(): void Schema::table('delayed_jobs', function (Blueprint $table) { $table->dropMorphs('entity'); $table->dropColumn('created_by'); + $table->dropColumn('is_cleared'); }); } }; diff --git a/openapi-src/V2/paths/Terrafund/post-v2-terrafund-clip-polygons-polygons.yml b/openapi-src/V2/paths/Terrafund/post-v2-terrafund-clip-polygons-polygons.yml index 09424689e..500460d55 100644 --- a/openapi-src/V2/paths/Terrafund/post-v2-terrafund-clip-polygons-polygons.yml +++ b/openapi-src/V2/paths/Terrafund/post-v2-terrafund-clip-polygons-polygons.yml @@ -12,6 +12,12 @@ parameters: items: type: string description: UUIDs of the polygon geometries to be fixed + entity_type: + type: string + description: The entity type of the polygon geometries to be fixed + entity_uuid: + type: string + description: The entity ID of the polygon geometries to be fixed responses: '200': description: A list of processed and unprocessed polygons From 79d312326284ed7ea07765ccb24d7e49e492bcc1 Mon Sep 17 00:00:00 2001 From: JORGE Date: Thu, 5 Dec 2024 10:54:41 -0400 Subject: [PATCH 06/19] [TM-1531] add to fix polygons entity --- .../V2/Terrafund/TerrafundClipGeometryController.php | 4 ++-- resources/docs/swagger-v2.yml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index f56dded8e..d01f8cc77 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -86,7 +86,7 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) 'processed_content' => 0, 'entity_id' => $sitePolygon->id, 'entity_type' => get_class($sitePolygon), - 'created_by' => $user->id + 'created_by' => $user->id, ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); @@ -144,7 +144,7 @@ public function clipOverlappingPolygons(Request $request) 'processed_content' => 0, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'created_by' => $user->id + 'created_by' => $user->id, ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); diff --git a/resources/docs/swagger-v2.yml b/resources/docs/swagger-v2.yml index 18b175d0b..895e2336a 100644 --- a/resources/docs/swagger-v2.yml +++ b/resources/docs/swagger-v2.yml @@ -99171,6 +99171,12 @@ paths: items: type: string description: UUIDs of the polygon geometries to be fixed + entity_type: + type: string + description: The entity type of the polygon geometries to be fixed + entity_uuid: + type: string + description: The entity ID of the polygon geometries to be fixed responses: '200': description: A list of processed and unprocessed polygons From e4b3655d2bdaa95db862a0f217a98a333fafa3ce Mon Sep 17 00:00:00 2001 From: JORGE Date: Thu, 5 Dec 2024 14:44:26 -0400 Subject: [PATCH 07/19] [TM-1531] store delayed data for uploads --- .../TerrafundCreateGeometryController.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 047dcbc3a..7a5c72e1f 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -235,9 +235,16 @@ function ($attribute, $value, $fail) { return response()->json($polygonLoaded->original, 200); } + $user = Auth::user(); + $entity = Site::where('uuid', $site_id)->firstOrFail(); + $redis_key = 'kml_file_' . uniqid(); Redis::set($redis_key, $geojsonContent, 'EX', 7200); - $delayedJob = DelayedJob::create(); + $delayedJob = DelayedJob::create([ + 'created_by' => $user->id, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity), + ]); $job = new InsertGeojsonToDBJob( $redis_key, @@ -394,10 +401,16 @@ public function uploadShapefile(Request $request) return response()->json($polygonLoaded->original, 200); } + $user = Auth::user(); + $entity = Site::where('uuid', $site_id)->firstOrFail(); $redis_key = 'shapefile_file_' . uniqid(); Redis::set($redis_key, $geojsonContent, 'EX', 7200); - $delayedJob = DelayedJob::create(); + $delayedJob = DelayedJob::create([ + 'created_by' => $user->id, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity), + ]); $job = new InsertGeojsonToDBJob( $redis_key, @@ -614,10 +627,16 @@ public function uploadGeoJSONFile(Request $request) return response()->json($polygonLoaded->original, 200); } + $user = Auth::user(); + $entity = Site::where('uuid', $site_id)->firstOrFail(); $redis_key = 'geojson_file_' . uniqid(); Redis::set($redis_key, $geojson_content, 'EX', 7200); - $delayedJob = DelayedJob::create(); + $delayedJob = DelayedJob::create([ + 'created_by' => $user->id, + 'entity_id' => $entity->id, + 'entity_type' => get_class($entity), + ]); $job = new InsertGeojsonToDBJob( $redis_key, From ff989d471473a74d6f097504e93927d9839137c1 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Thu, 5 Dec 2024 15:00:20 -0400 Subject: [PATCH 08/19] [TM-1531] send mails when job for upload, check or fix is complete --- app/Jobs/FixPolygonOverlapJob.php | 11 ++++++ app/Jobs/InsertGeojsonToDBJob.php | 14 +++++++- app/Jobs/RunSitePolygonsValidationJob.php | 12 +++++++ app/Mail/PolygonOperationsComplete.php | 35 +++++++++++++++++++ .../seeders/LocalizationKeysTableSeeder.php | 6 ++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/Mail/PolygonOperationsComplete.php diff --git a/app/Jobs/FixPolygonOverlapJob.php b/app/Jobs/FixPolygonOverlapJob.php index 3f610f852..5dcfeab48 100644 --- a/app/Jobs/FixPolygonOverlapJob.php +++ b/app/Jobs/FixPolygonOverlapJob.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Http\Middleware\SetAuthenticatedUserForJob; +use App\Mail\PolygonOperationsComplete; use App\Models\DelayedJob; use App\Models\DelayedJobProgress; use App\Services\PolygonService; @@ -16,6 +17,7 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Mail; use Throwable; class FixPolygonOverlapJob implements ShouldQueue @@ -66,6 +68,7 @@ public function handle(): void try { $delayedJob = DelayedJobProgress::findOrFail($this->delayed_job_id); $user = Auth::user(); + $site = $delayedJob->entity; if ($user) { $polygonsClipped = App::make(PolygonService::class)->processClippedPolygons($this->polygonUuids, $this->delayed_job_id); $delayedJob->update([ @@ -74,6 +77,14 @@ public function handle(): void 'status_code' => Response::HTTP_OK, 'progress' => 100, ]); + + Mail::to($user->email_address) + ->send(new PolygonOperationsComplete( + $site, + 'Fix', + $user, + now() + )); } } catch (Exception $e) { Log::error('Error in Fix Polygon Overlap Job: ' . $e->getMessage()); diff --git a/app/Jobs/InsertGeojsonToDBJob.php b/app/Jobs/InsertGeojsonToDBJob.php index a07752d5b..a6caf7582 100755 --- a/app/Jobs/InsertGeojsonToDBJob.php +++ b/app/Jobs/InsertGeojsonToDBJob.php @@ -2,19 +2,21 @@ namespace App\Jobs; +use App\Mail\PolygonOperationsComplete; use App\Models\DelayedJob; use App\Services\PolygonService; use App\Services\SiteService; use Exception; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Response; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Redis; class InsertGeojsonToDBJob implements ShouldQueue @@ -51,6 +53,8 @@ public function __construct(string $redis_key, string $delayed_job_id, ?string $ public function handle(PolygonService $service) { $delayedJob = DelayedJob::findOrFail($this->delayed_job_id); + $user = $delayedJob->creator; + $site = $delayedJob->entity; try { $geojsonContent = Redis::get($this->redis_key); @@ -86,6 +90,14 @@ public function handle(PolygonService $service) 'status_code' => Response::HTTP_OK, ]); + Mail::to($user->email_address) + ->send(new PolygonOperationsComplete( + $site, + 'Upload', + $user, + now() + )); + } catch (Exception $e) { Log::error('Error in InsertGeojsonToDBJob: ' . $e->getMessage()); $delayedJob->update([ diff --git a/app/Jobs/RunSitePolygonsValidationJob.php b/app/Jobs/RunSitePolygonsValidationJob.php index 9bba9777c..34f4f5a98 100644 --- a/app/Jobs/RunSitePolygonsValidationJob.php +++ b/app/Jobs/RunSitePolygonsValidationJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Mail\PolygonOperationsComplete; use App\Models\DelayedJob; use App\Models\DelayedJobProgress; use App\Services\PolygonValidationService; @@ -14,6 +15,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Mail; class RunSitePolygonsValidationJob implements ShouldQueue { @@ -50,6 +52,8 @@ public function handle(PolygonValidationService $validationService) { try { $delayedJob = DelayedJobProgress::findOrFail($this->delayed_job_id); + $user = $delayedJob->creator; + $site = $delayedJob->entity; foreach ($this->sitePolygonsUuids as $polygonUuid) { $request = new Request(['uuid' => $polygonUuid]); $validationService->validateOverlapping($request); @@ -74,6 +78,14 @@ public function handle(PolygonValidationService $validationService) 'progress' => 100, ]); + Mail::to($user->email_address) + ->send(new PolygonOperationsComplete( + $site, + 'Check', + $user, + now() + )); + } catch (Exception $e) { Log::error('Error in RunSitePolygonsValidationJob: ' . $e->getMessage()); diff --git a/app/Mail/PolygonOperationsComplete.php b/app/Mail/PolygonOperationsComplete.php new file mode 100644 index 000000000..3d7b74726 --- /dev/null +++ b/app/Mail/PolygonOperationsComplete.php @@ -0,0 +1,35 @@ +site = $site; + $this->operation = $operation; + $this->completedAt = $completedAt; + + $this->setSubjectKey('polygon-validation.subject') + ->setTitleKey('polygon-validation.title') + ->setBodyKey('polygon-validation.body') + ->setParams([ + '{operation}' => e($operation), + '{operationUpper}' => strtoupper(e($operation)), + '{siteName}' => e($site->name), + '{completedTime}' => $completedAt->format('H:i'), + ]) + ->setCta('polygon-validation.cta'); + + $this->link = '/sites/' . $site->uuid; + $this->transactional = true; + } +} diff --git a/database/seeders/LocalizationKeysTableSeeder.php b/database/seeders/LocalizationKeysTableSeeder.php index 1676b6c68..8f1f68c3d 100644 --- a/database/seeders/LocalizationKeysTableSeeder.php +++ b/database/seeders/LocalizationKeysTableSeeder.php @@ -179,6 +179,12 @@ public function run(): void 'TerraMatch Support'); $this->createLocalizationKey('send-login-details.cta', 'Set Password'); + // polygon-operations-complete + $this->createLocalizationKey('polygon-validation.subject', 'Your TerraMatch Polygon {operation} is Complete'); + $this->createLocalizationKey('polygon-validation.title', 'YOUR POLYGON {operationUpper} IS COMPLETE'); + $this->createLocalizationKey('polygon-validation.body', 'Your {operation} for Site {siteName} completed at {completedTime} GMT.'); + $this->createLocalizationKey('polygon-validation.cta', 'OPEN SITE'); + // satellite-map-created $this->createLocalizationKey('satellite-map-created.subject', 'Remote Sensing Map Received'); $this->createLocalizationKey('satellite-map-created.title', 'Remote Sensing Map Received'); From e56660c087024093a5c8e8dfc93ed6346e339050 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Thu, 5 Dec 2024 15:28:23 -0400 Subject: [PATCH 09/19] [TM-1531] send correct user for mails --- app/Jobs/FixPolygonOverlapJob.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Jobs/FixPolygonOverlapJob.php b/app/Jobs/FixPolygonOverlapJob.php index 5dcfeab48..16850a39b 100644 --- a/app/Jobs/FixPolygonOverlapJob.php +++ b/app/Jobs/FixPolygonOverlapJob.php @@ -69,6 +69,7 @@ public function handle(): void $delayedJob = DelayedJobProgress::findOrFail($this->delayed_job_id); $user = Auth::user(); $site = $delayedJob->entity; + $userForMail = $delayedJob->creator; if ($user) { $polygonsClipped = App::make(PolygonService::class)->processClippedPolygons($this->polygonUuids, $this->delayed_job_id); $delayedJob->update([ @@ -82,7 +83,7 @@ public function handle(): void ->send(new PolygonOperationsComplete( $site, 'Fix', - $user, + $userForMail, now() )); } From 5e2c3f0288fdb67acb3a49f4ad4a1ca4c78798bc Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Fri, 6 Dec 2024 15:13:46 -0400 Subject: [PATCH 10/19] [TM-1531] modify column name on delayed jobs table --- ...fy_columns_names_in_delayed_jobs_table.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php diff --git a/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php b/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php new file mode 100644 index 000000000..ecf8de80a --- /dev/null +++ b/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php @@ -0,0 +1,28 @@ +renameColumn('proccess_message', 'progress_message'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('delayed_jobs', function (Blueprint $table) { + $table->renameColumn('progress_message', 'proccess_message'); + }); + } +}; From a97200c2b4ffff2af963a77fcc19fe24467362d7 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Fri, 6 Dec 2024 16:47:45 -0400 Subject: [PATCH 11/19] [TM-1531] change attribute name to progress message --- app/Http/Resources/DelayedJobProgressResource.php | 2 +- app/Models/DelayedJobProgress.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Resources/DelayedJobProgressResource.php b/app/Http/Resources/DelayedJobProgressResource.php index 234c2ad8b..59c1dccfe 100644 --- a/app/Http/Resources/DelayedJobProgressResource.php +++ b/app/Http/Resources/DelayedJobProgressResource.php @@ -19,7 +19,7 @@ public function toArray(Request $request): array 'job_uuid' => $this->uuid, 'proccessed_content' => $this->processed_content, 'total_content' => $this->total_content, - 'proccess_message' => $this->proccess_message, + 'progress_message' => $this->progress_message, ]; } } diff --git a/app/Models/DelayedJobProgress.php b/app/Models/DelayedJobProgress.php index a01fda4f2..8dcd57867 100644 --- a/app/Models/DelayedJobProgress.php +++ b/app/Models/DelayedJobProgress.php @@ -11,13 +11,13 @@ public function __construct(array $attributes = []) $this->fillable = array_merge($this->fillable, [ 'processed_content', 'total_content', - 'proccess_message', + 'progress_message', ]); $this->casts = array_merge($this->casts, [ 'processed_content' => 'integer', 'total_content' => 'integer', - 'proccess_message' => 'string', + 'progress_message' => 'string', ]); } @@ -30,7 +30,7 @@ public function processMessage(): string $progress = 0; } - return $this->proccess_message = 'Running '. $this->processed_content .' out of ' + return $this->progress_message = 'Running '. $this->processed_content .' out of ' .$this->total_content. ' polygons ('.$progress.'%)' ; } } From f72532ca637bea1f5aafa76832eda5660b19595c Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Mon, 9 Dec 2024 11:30:57 -0400 Subject: [PATCH 12/19] [TM-1531] lint fix --- ...12_06_190555_modify_columns_names_in_delayed_jobs_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php b/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php index ecf8de80a..b13e0e2e9 100644 --- a/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php +++ b/database/migrations/2024_12_06_190555_modify_columns_names_in_delayed_jobs_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. */ From 986a0a56aad734d6bd2542865e89df882e215a14 Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 10 Dec 2024 10:54:09 -0400 Subject: [PATCH 13/19] [TM-1531] change to is_aknowledged value --- .../TerrafundClipGeometryController.php | 3 ++ .../TerrafundCreateGeometryController.php | 5 +++ app/Models/DelayedJob.php | 2 +- ..._12_09_212253_change_is_cleared_values.php | 37 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_12_09_212253_change_is_cleared_values.php diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index d01f8cc77..4f4b22f4b 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -31,6 +31,7 @@ public function clipOverlappingPolygonsBySite(string $uuid) 'created_by' => $user->id, 'entity_id' => $site->id, 'entity_type' => get_class($site), + 'is_acknowledged' => false ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); @@ -87,6 +88,7 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) 'entity_id' => $sitePolygon->id, 'entity_type' => get_class($sitePolygon), 'created_by' => $user->id, + 'is_acknowledged' => false ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); @@ -145,6 +147,7 @@ public function clipOverlappingPolygons(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'created_by' => $user->id, + 'is_acknowledged' => false ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 7a5c72e1f..0508c6bc3 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -244,6 +244,7 @@ function ($attribute, $value, $fail) { 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), + 'is_acknowledged' => false ]); $job = new InsertGeojsonToDBJob( @@ -410,6 +411,7 @@ public function uploadShapefile(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), + 'is_acknowledged' => false ]); $job = new InsertGeojsonToDBJob( @@ -636,6 +638,7 @@ public function uploadGeoJSONFile(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), + 'is_acknowledged' => false ]); $job = new InsertGeojsonToDBJob( @@ -1247,6 +1250,7 @@ public function runSiteValidationPolygon(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), + 'is_acknowledged' => false ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1275,6 +1279,7 @@ public function runPolygonsValidation(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), + 'is_acknowledged' => false ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); diff --git a/app/Models/DelayedJob.php b/app/Models/DelayedJob.php index 95ee0a576..497f4e0a5 100644 --- a/app/Models/DelayedJob.php +++ b/app/Models/DelayedJob.php @@ -18,7 +18,7 @@ class DelayedJob extends Model protected $table = 'delayed_jobs'; - protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by']; + protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by', 'is_acknowledged']; protected $casts = [ 'uuid' => 'string', diff --git a/database/migrations/2024_12_09_212253_change_is_cleared_values.php b/database/migrations/2024_12_09_212253_change_is_cleared_values.php new file mode 100644 index 000000000..3e304a2c7 --- /dev/null +++ b/database/migrations/2024_12_09_212253_change_is_cleared_values.php @@ -0,0 +1,37 @@ +dropColumn('is_cleared'); + } + if (!Schema::hasColumn('delayed_jobs', 'is_acknowledged')) { + $table->boolean('is_acknowledged')->default(true); + } + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('delayed_jobs', function (Blueprint $table) { + if (Schema::hasColumn('delayed_jobs', 'is_acknowledged')) { + $table->dropColumn('is_acknowledged'); + } + if (!Schema::hasColumn('delayed_jobs', 'is_cleared')) { + $table->boolean('is_cleared')->default(false); + } + }); + } +}; From a367e9932ae58c06db61365a0c83614629ffb47a Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 10 Dec 2024 14:21:51 -0400 Subject: [PATCH 14/19] [TM-1531] change created_by type, change to is_acknowledge --- .../TerrafundClipGeometryController.php | 6 +++--- .../TerrafundCreateGeometryController.php | 10 +++++----- ...4_12_09_212253_change_is_cleared_values.php | 18 +++++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index 4f4b22f4b..04205edac 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -31,7 +31,7 @@ public function clipOverlappingPolygonsBySite(string $uuid) 'created_by' => $user->id, 'entity_id' => $site->id, 'entity_type' => get_class($site), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); @@ -88,7 +88,7 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) 'entity_id' => $sitePolygon->id, 'entity_type' => get_class($sitePolygon), 'created_by' => $user->id, - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); @@ -147,7 +147,7 @@ public function clipOverlappingPolygons(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'created_by' => $user->id, - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 0508c6bc3..a2e41ca26 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -244,7 +244,7 @@ function ($attribute, $value, $fail) { 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new InsertGeojsonToDBJob( @@ -411,7 +411,7 @@ public function uploadShapefile(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new InsertGeojsonToDBJob( @@ -638,7 +638,7 @@ public function uploadGeoJSONFile(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new InsertGeojsonToDBJob( @@ -1250,7 +1250,7 @@ public function runSiteValidationPolygon(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1279,7 +1279,7 @@ public function runPolygonsValidation(Request $request) 'created_by' => $user->id, 'entity_id' => $entity->id, 'entity_type' => get_class($entity), - 'is_acknowledged' => false + 'is_acknowledged' => false, ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); diff --git a/database/migrations/2024_12_09_212253_change_is_cleared_values.php b/database/migrations/2024_12_09_212253_change_is_cleared_values.php index 3e304a2c7..972664bb5 100644 --- a/database/migrations/2024_12_09_212253_change_is_cleared_values.php +++ b/database/migrations/2024_12_09_212253_change_is_cleared_values.php @@ -11,12 +11,11 @@ public function up(): void { Schema::table('delayed_jobs', function (Blueprint $table) { - if (Schema::hasColumn('delayed_jobs', 'is_cleared')) { - $table->dropColumn('is_cleared'); - } - if (!Schema::hasColumn('delayed_jobs', 'is_acknowledged')) { - $table->boolean('is_acknowledged')->default(true); - } + $table->unsignedBigInteger('created_by')->nullable()->change(); + + $table->dropColumn('is_cleared'); + + $table->boolean('is_acknowledged')->default(true); }); } @@ -26,10 +25,15 @@ public function up(): void public function down(): void { Schema::table('delayed_jobs', function (Blueprint $table) { + if (Schema::hasColumn('delayed_jobs', 'createdBy')) { + $table->string('createdBy')->nullable()->change(); + } + if (Schema::hasColumn('delayed_jobs', 'is_acknowledged')) { $table->dropColumn('is_acknowledged'); } - if (!Schema::hasColumn('delayed_jobs', 'is_cleared')) { + + if (! Schema::hasColumn('delayed_jobs', 'is_cleared')) { $table->boolean('is_cleared')->default(false); } }); From cdff5673f6c5f0d1ca27e6dfbf1d185d61ded972 Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 17 Dec 2024 11:39:24 -0400 Subject: [PATCH 15/19] [TM-1531] add name to delayed jobs --- .../TerrafundClipGeometryController.php | 3 ++ .../TerrafundCreateGeometryController.php | 5 ++++ app/Models/DelayedJob.php | 2 +- .../2024_12_17_150134_add_name_to_jobs.php | 29 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_12_17_150134_add_name_to_jobs.php diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index 04205edac..ff806a511 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -32,6 +32,7 @@ public function clipOverlappingPolygonsBySite(string $uuid) 'entity_id' => $site->id, 'entity_type' => get_class($site), 'is_acknowledged' => false, + 'name' => 'Polygon Fix', ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); @@ -89,6 +90,7 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) 'entity_type' => get_class($sitePolygon), 'created_by' => $user->id, 'is_acknowledged' => false, + 'name' => 'Polygon Fix' ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); @@ -148,6 +150,7 @@ public function clipOverlappingPolygons(Request $request) 'entity_type' => get_class($entity), 'created_by' => $user->id, 'is_acknowledged' => false, + 'name' => 'Polygon Fix', ]); $job = new FixPolygonOverlapJob($delayedJob->id, $polygonUuids, $user->id); dispatch($job); diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index a2e41ca26..1779ebdbd 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -245,6 +245,7 @@ function ($attribute, $value, $fail) { 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, + 'name' => "Polygon Upload" ]); $job = new InsertGeojsonToDBJob( @@ -412,6 +413,7 @@ public function uploadShapefile(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, + 'name' => "Polygon Upload" ]); $job = new InsertGeojsonToDBJob( @@ -639,6 +641,7 @@ public function uploadGeoJSONFile(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, + 'name' => "Polygon Upload" ]); $job = new InsertGeojsonToDBJob( @@ -1251,6 +1254,7 @@ public function runSiteValidationPolygon(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, + 'name' => "Polygon validation" ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1280,6 +1284,7 @@ public function runPolygonsValidation(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, + 'name' => "Polygon validation" ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); diff --git a/app/Models/DelayedJob.php b/app/Models/DelayedJob.php index 497f4e0a5..51e547df7 100644 --- a/app/Models/DelayedJob.php +++ b/app/Models/DelayedJob.php @@ -18,7 +18,7 @@ class DelayedJob extends Model protected $table = 'delayed_jobs'; - protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by', 'is_acknowledged']; + protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by', 'is_acknowledged', 'name']; protected $casts = [ 'uuid' => 'string', diff --git a/database/migrations/2024_12_17_150134_add_name_to_jobs.php b/database/migrations/2024_12_17_150134_add_name_to_jobs.php new file mode 100644 index 000000000..e1389f743 --- /dev/null +++ b/database/migrations/2024_12_17_150134_add_name_to_jobs.php @@ -0,0 +1,29 @@ +string('name')->nullable()->after('id'); // Adjust 'after' based on the desired column position + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('delayed_jobs', function (Blueprint $table) { + $table->dropColumn('name'); + }); + } + +}; From 6d416849ed41b3166e7ec3d59d4b5b90b9f129f8 Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 17 Dec 2024 11:58:22 -0400 Subject: [PATCH 16/19] [TM-1531] lint --- .../V2/Terrafund/TerrafundClipGeometryController.php | 2 +- .../V2/Terrafund/TerrafundCreateGeometryController.php | 10 +++++----- .../migrations/2024_12_17_150134_add_name_to_jobs.php | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index ff806a511..b9e699c8a 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -90,7 +90,7 @@ public function clipOverlappingPolygonsOfProjectBySite(string $uuid) 'entity_type' => get_class($sitePolygon), 'created_by' => $user->id, 'is_acknowledged' => false, - 'name' => 'Polygon Fix' + 'name' => 'Polygon Fix', ]); $job = new FixPolygonOverlapJob($delayedJob->id, $uniquePolygonUuids, $user->id); dispatch($job); diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 1779ebdbd..bddbd5c1e 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -245,7 +245,7 @@ function ($attribute, $value, $fail) { 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => "Polygon Upload" + 'name' => 'Polygon Upload', ]); $job = new InsertGeojsonToDBJob( @@ -413,7 +413,7 @@ public function uploadShapefile(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => "Polygon Upload" + 'name' => 'Polygon Upload', ]); $job = new InsertGeojsonToDBJob( @@ -641,7 +641,7 @@ public function uploadGeoJSONFile(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => "Polygon Upload" + 'name' => 'Polygon Upload', ]); $job = new InsertGeojsonToDBJob( @@ -1254,7 +1254,7 @@ public function runSiteValidationPolygon(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => "Polygon validation" + 'name' => 'Polygon validation', ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1284,7 +1284,7 @@ public function runPolygonsValidation(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => "Polygon validation" + 'name' => 'Polygon validation', ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); diff --git a/database/migrations/2024_12_17_150134_add_name_to_jobs.php b/database/migrations/2024_12_17_150134_add_name_to_jobs.php index e1389f743..088b7b733 100644 --- a/database/migrations/2024_12_17_150134_add_name_to_jobs.php +++ b/database/migrations/2024_12_17_150134_add_name_to_jobs.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. */ @@ -15,7 +14,7 @@ public function up(): void $table->string('name')->nullable()->after('id'); // Adjust 'after' based on the desired column position }); } - + /** * Reverse the migrations. */ @@ -25,5 +24,4 @@ public function down(): void $table->dropColumn('name'); }); } - }; From 7b8051bc18f0e3b99f91b6c1e7c900c9a46b9be9 Mon Sep 17 00:00:00 2001 From: JORGE Date: Tue, 17 Dec 2024 12:11:43 -0400 Subject: [PATCH 17/19] [TM-1531] remove comment --- database/migrations/2024_12_17_150134_add_name_to_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2024_12_17_150134_add_name_to_jobs.php b/database/migrations/2024_12_17_150134_add_name_to_jobs.php index 088b7b733..edc2c5c17 100644 --- a/database/migrations/2024_12_17_150134_add_name_to_jobs.php +++ b/database/migrations/2024_12_17_150134_add_name_to_jobs.php @@ -11,7 +11,7 @@ public function up(): void { Schema::table('delayed_jobs', function (Blueprint $table) { - $table->string('name')->nullable()->after('id'); // Adjust 'after' based on the desired column position + $table->string('name')->nullable()->after('id'); }); } From 1a743a3f7118f6eb2ddbddbd9a8e461f0522680c Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 18 Dec 2024 12:59:01 -0400 Subject: [PATCH 18/19] [TM-1531] correct name for job --- .../V2/Terrafund/TerrafundCreateGeometryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index bddbd5c1e..0cc2df512 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -1254,7 +1254,7 @@ public function runSiteValidationPolygon(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => 'Polygon validation', + 'name' => 'Polygon Validation', ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $sitePolygonsUuids); dispatch($job); @@ -1284,7 +1284,7 @@ public function runPolygonsValidation(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => 'Polygon validation', + 'name' => 'Polygon Validation', ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job); From a72ba660377f690a6605066e1f3bc68205915f16 Mon Sep 17 00:00:00 2001 From: JORGE Date: Wed, 18 Dec 2024 14:39:22 -0400 Subject: [PATCH 19/19] [TM-1531] lint --- .../V2/Terrafund/TerrafundCreateGeometryController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index f9de03dad..0cc2df512 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -1284,7 +1284,7 @@ public function runPolygonsValidation(Request $request) 'entity_id' => $entity->id, 'entity_type' => get_class($entity), 'is_acknowledged' => false, - 'name' => 'Polygon Validation' + 'name' => 'Polygon Validation', ]); $job = new RunSitePolygonsValidationJob($delayedJob->id, $uuids); dispatch($job);