feat(console): tambah parameter queue_name pada ProcessDailyStaging command
Menambahkan parameter queue_name untuk memberikan fleksibilitas dalam pemilihan queue saat menjalankan proses staging: - Menambahkan parameter queue_name dengan default value 'default' pada signature command - Memperbarui description command untuk mencantumkan informasi queue name - Menambahkan function-level comment pada class dan method handle sesuai standar - Menambahkan queue_name ke semua log entries untuk tracking dan debugging yang lebih baik - Menambahkan output queue name pada info message untuk feedback user - Memperbarui controller call untuk mengirim queue_name sebagai parameter - Menambahkan queue_name ke error logging untuk debugging yang lebih efektif - Mempertahankan backward compatibility dengan parameter opsional - Meningkatkan fleksibilitas dalam manajemen queue untuk proses staging - Memungkinkan penggunaan queue khusus untuk prioritas atau isolasi proses
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Console;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Webstatement\Http\Controllers\StagingController;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ProcessDailyMigration extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webstatement:process-daily-migration
|
||||
{--process_parameter= : To process migration parameter true/false}
|
||||
{--period= : Period to process (default: -1 day, format: Ymd or relative date)}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process data migration for the specified period (default: previous day)';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$processParameter = $this->option('process_parameter');
|
||||
$period = $this->option('period');
|
||||
|
||||
// Log start of process
|
||||
Log::info('Starting daily data migration process', [
|
||||
'process_parameter' => $processParameter ?? 'false',
|
||||
'period' => $period ?? '-1 day'
|
||||
]);
|
||||
|
||||
$this->info('Starting daily data migration process...');
|
||||
$this->info('Process Parameter: ' . ($processParameter ?? 'False'));
|
||||
$this->info('Period: ' . ($period ?? '-1 day (default)'));
|
||||
|
||||
try {
|
||||
$controller = app(StagingController::class);
|
||||
$response = $controller->index($processParameter, $period);
|
||||
|
||||
$responseData = json_decode($response->getContent(), true);
|
||||
$message = $responseData['message'] ?? 'Process completed';
|
||||
|
||||
$this->info($message);
|
||||
Log::info('Daily migration process completed successfully', ['message' => $message]);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = 'Error processing daily migration: ' . $e->getMessage();
|
||||
$this->error($errorMessage);
|
||||
Log::error($errorMessage, ['exception' => $e->getTraceAsString()]);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
85
app/Console/ProcessDailyStaging.php
Normal file
85
app/Console/ProcessDailyStaging.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Console;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Webstatement\Http\Controllers\StagingController;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Console command untuk memproses data staging harian
|
||||
* Command ini dapat dijalankan secara manual atau dijadwalkan
|
||||
*/
|
||||
class ProcessDailyStaging extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webstatement:process-daily-staging
|
||||
{--process_parameter= : To process staging parameter true/false}
|
||||
{--period= : Period to process (default: -1 day, format: Ymd or relative date)}
|
||||
{--queue_name=default : Queue name untuk menjalankan job (default: default)}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process data staging for the specified period (default: previous day) dengan queue name yang dapat dikustomisasi';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* Menjalankan proses staging data harian
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$processParameter = $this->option('process_parameter');
|
||||
$period = $this->option('period');
|
||||
$queueName = $this->option('queue_name');
|
||||
|
||||
// Log start of process
|
||||
Log::info('Starting daily data staging process', [
|
||||
'process_parameter' => $processParameter ?? 'false',
|
||||
'period' => $period ?? '-1 day',
|
||||
'queue_name' => $queueName ?? 'default'
|
||||
]);
|
||||
|
||||
$this->info('Starting daily data staging process...');
|
||||
$this->info('Process Parameter: ' . ($processParameter ?? 'False'));
|
||||
$this->info('Period: ' . ($period ?? '-1 day (default)'));
|
||||
$this->info('Queue Name: ' . ($queueName ?? 'default'));
|
||||
|
||||
try {
|
||||
$controller = app(StagingController::class);
|
||||
|
||||
// Pass queue name to controller if needed
|
||||
// Jika controller membutuhkan queue name, bisa ditambahkan sebagai parameter
|
||||
$response = $controller->index($processParameter, $period, $queueName);
|
||||
|
||||
$responseData = json_decode($response->getContent(), true);
|
||||
$message = $responseData['message'] ?? 'Process completed';
|
||||
|
||||
$this->info($message);
|
||||
Log::info('Daily staging process completed successfully', [
|
||||
'message' => $message,
|
||||
'queue_name' => $queueName ?? 'default'
|
||||
]);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = 'Error processing daily staging: ' . $e->getMessage();
|
||||
$this->error($errorMessage);
|
||||
Log::error($errorMessage, [
|
||||
'exception' => $e->getTraceAsString(),
|
||||
'queue_name' => $queueName ?? 'default'
|
||||
]);
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ use Modules\Webstatement\Console\{
|
||||
CombinePdf,
|
||||
ConvertHtmlToPdf,
|
||||
ExportDailyStatements,
|
||||
ProcessDailyMigration,
|
||||
ProcessDailyStaging,
|
||||
ExportPeriodStatements,
|
||||
UpdateAllAtmCardsCommand,
|
||||
CheckEmailProgressCommand,
|
||||
@@ -68,7 +68,7 @@ class WebstatementServiceProvider extends ServiceProvider
|
||||
$this->commands([
|
||||
GenerateBiayakartuCommand::class,
|
||||
GenerateBiayaKartuCsvCommand::class,
|
||||
ProcessDailyMigration::class,
|
||||
ProcessDailyStaging::class,
|
||||
ExportDailyStatements::class,
|
||||
CombinePdf::class,
|
||||
ConvertHtmlToPdf::class,
|
||||
|
||||
Reference in New Issue
Block a user