refactor(webstatement): ubah parameter periode dari array menjadi string
- Mengubah parameter pada metode `ProcessCategoryData` di `MigrasiController` dari array menjadi string untuk keseragaman dengan metode lainnya. - Memperbarui konstruksi parameter pada instansi `ProcessCategoryDataJob` untuk menerima tipe data string sebagai pengganti array. - Menghilangkan iterasi array `periods` pada `ProcessCategoryDataJob` dan menerapkan logika langsung pada single `period`. - Menyesuaikan validasi periode untuk mengabaikan folder `_parameter` dalam proses. - Memperlihatkan log lebih spesifik jika file tidak ditemukan, atau format kolom tidak sesuai ekspektasi. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -252,7 +252,7 @@ class MigrasiController extends Controller
|
||||
return response()->json(["message" => "Period {$period} folder not found in SFTP storage"], 404);
|
||||
}
|
||||
|
||||
$this->ProcessCategoryData([$period]);
|
||||
$this->ProcessCategoryData($period);
|
||||
$this->ProcessCompanyData([$period]);
|
||||
|
||||
$this->processCustomerData([$period]);
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $periods;
|
||||
protected $period;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(array $periods = [])
|
||||
public function __construct(string $period = '')
|
||||
{
|
||||
$this->periods = $periods;
|
||||
$this->period = $period;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,27 +38,26 @@
|
||||
$processedCount = 0;
|
||||
$errorCount = 0;
|
||||
|
||||
if (empty($this->periods)) {
|
||||
Log::warning('No periods provided for category data processing');
|
||||
if (empty($this->period)) {
|
||||
Log::warning('No period provided for category data processing');
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->periods as $period) {
|
||||
// Skip the _parameter folder
|
||||
if ($period === '_parameter') {
|
||||
if ($this->period === '_parameter') {
|
||||
Log::info("Skipping _parameter folder");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct the filename based on the period folder name
|
||||
$filename = "$period.ST.CATEGORY.csv";
|
||||
$filePath = "$period/$filename";
|
||||
$filename = "{$this->period}.ST.CATEGORY.csv";
|
||||
$filePath = "{$this->period}/$filename";
|
||||
|
||||
Log::info("Processing category file: $filePath");
|
||||
|
||||
if (!$disk->exists($filePath)) {
|
||||
Log::warning("File not found: $filePath");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a temporary local copy of the file
|
||||
@@ -126,7 +125,6 @@
|
||||
} else {
|
||||
Log::error("Unable to open file: $filePath");
|
||||
}
|
||||
}
|
||||
|
||||
Log::info("Category data processing completed. Total processed: $processedCount, Total errors: $errorCount");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user