Skip to content

Commit

Permalink
[TM-1531] delayed job with data (#617)
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

* [TM-1531] add name to delayed jobs

* [TM-1531] lint

* [TM-1531] remove comment

---------

Co-authored-by: cesarLima1 <[email protected]>
  • Loading branch information
egrojMonroy and cesarLima1 authored Dec 17, 2024
1 parent ffdbff1 commit e3d0e8c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
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', 'is_acknowledged'];
protected $fillable = ['uuid', 'status', 'status_code', 'payload', 'entity_type', 'entity_id', 'created_by', 'is_acknowledged', 'name'];

protected $casts = [
'uuid' => 'string',
Expand Down
27 changes: 27 additions & 0 deletions database/migrations/2024_12_17_150134_add_name_to_jobs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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->string('name')->nullable()->after('id');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('delayed_jobs', function (Blueprint $table) {
$table->dropColumn('name');
});
}
};

0 comments on commit e3d0e8c

Please sign in to comment.