Add RunAllFetchs command to execute currency and gold rate fetching jobs sequentially
- Introduced a new console command `RunAllFetchs` to streamline the execution of `FetchCurrencyRates`, `FetchGoldRates`, and `MergeCurrencyAndGoldRates` jobs. - Implemented synchronous dispatching of jobs with timing results displayed in a table format for performance monitoring. - This command enhances the application's ability to fetch and merge financial data efficiently in a single execution step.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Jobs\FetchCurrencyRates;
|
||||
use App\Jobs\FetchGoldRates;
|
||||
use App\Jobs\MergeCurrencyAndGoldRates;
|
||||
|
||||
class RunAllFetchs extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'run-all-fetchs';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
|
||||
$results = [];
|
||||
|
||||
$start = microtime(true);
|
||||
FetchCurrencyRates::dispatchSync();
|
||||
$duration = microtime(true) - $start;
|
||||
$results[] = ['FetchCurrencyRates', number_format($duration, 2)];
|
||||
|
||||
$start = microtime(true);
|
||||
FetchGoldRates::dispatchSync();
|
||||
$duration = microtime(true) - $start;
|
||||
$results[] = ['FetchGoldRates', number_format($duration, 2)];
|
||||
|
||||
$start = microtime(true);
|
||||
MergeCurrencyAndGoldRates::dispatchSync();
|
||||
$duration = microtime(true) - $start;
|
||||
$results[] = ['MergeCurrencyAndGoldRates', number_format($duration, 2)];
|
||||
|
||||
// Tablo formatında yazdırma
|
||||
$this->table(['İşlem', 'Süre (saniye)'], $results);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user