Skip to content

Commit

Permalink
[TM-1531] delayed job with data (#610)
Browse files Browse the repository at this point in the history
* [TM-1531] entity record and creator to delayedJOb

* [TM-1531] add useer to endpoint

* [TM-1531] add entity data for polygons validations

* [TM-1531] lint

* [TM-1531] add is_cleared

* [TM-1531] add to fix polygons entity

* [TM-1531] store delayed data for uploads

* [TM-1531] send mails when job for upload, check or fix is complete

* [TM-1531] send correct user for mails

* [TM-1531] modify column name on delayed jobs table

* [TM-1531] change attribute name to progress message

* [TM-1531] lint fix

* [TM-1531] change to is_aknowledged value

* [TM-1531] change created_by type, change to is_acknowledge

---------

Co-authored-by: JORGE <[email protected]>
  • Loading branch information
cesarLima1 and egrojMonroy authored Dec 13, 2024
1 parent 8a0dc46 commit 3a83f0b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/DelayedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
41 changes: 41 additions & 0 deletions database/migrations/2024_12_09_212253_change_is_cleared_values.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('delayed_jobs', function (Blueprint $table) {
$table->unsignedBigInteger('created_by')->nullable()->change();

$table->dropColumn('is_cleared');

$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', 'createdBy')) {
$table->string('createdBy')->nullable()->change();
}

if (Schema::hasColumn('delayed_jobs', 'is_acknowledged')) {
$table->dropColumn('is_acknowledged');
}

if (! Schema::hasColumn('delayed_jobs', 'is_cleared')) {
$table->boolean('is_cleared')->default(false);
}
});
}
};

0 comments on commit 3a83f0b

Please sign in to comment.