İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ExecuteWeldlogSyncJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 300;
|
||||
public $tries = 1;
|
||||
public $maxExceptions = 1;
|
||||
|
||||
protected $tableName;
|
||||
protected $recordId;
|
||||
|
||||
/**
|
||||
* @param string $tableName Log test type table name
|
||||
* @param int $recordId Record ID in the table
|
||||
*/
|
||||
public function __construct(string $tableName, int $recordId)
|
||||
{
|
||||
$this->tableName = $tableName;
|
||||
$this->recordId = $recordId;
|
||||
|
||||
$this->onQueue('save-trigger');
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
Log::info("=== ExecuteWeldlogSyncJob STARTED ===", [
|
||||
'table_name' => $this->tableName,
|
||||
'record_id' => $this->recordId,
|
||||
]);
|
||||
|
||||
try {
|
||||
// Kayıt verisini kuyruk içinde çek (response'u yavaşlatmaz)
|
||||
$recordData = db($this->tableName)->where('id', $this->recordId)->first();
|
||||
|
||||
if (!$recordData) {
|
||||
Log::warning("ExecuteWeldlogSyncJob: Record not found", [
|
||||
'table_name' => $this->tableName,
|
||||
'record_id' => $this->recordId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = (array) $recordData;
|
||||
|
||||
if (function_exists('logToWeldlogUpdate')) {
|
||||
logToWeldlogUpdate($data);
|
||||
}
|
||||
|
||||
if (function_exists('logToWPQUpdate')) {
|
||||
logToWPQUpdate($data, $this->tableName);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::error("ExecuteWeldlogSyncJob failed", [
|
||||
'table_name' => $this->tableName,
|
||||
'record_id' => $this->recordId,
|
||||
'error' => $th->getMessage(),
|
||||
]);
|
||||
throw $th;
|
||||
}
|
||||
|
||||
Log::info("=== ExecuteWeldlogSyncJob COMPLETED ===", [
|
||||
'table_name' => $this->tableName,
|
||||
'record_id' => $this->recordId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function tags(): array
|
||||
{
|
||||
return [
|
||||
"WeldlogSync:{$this->tableName}",
|
||||
"RecordId:{$this->recordId}",
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user