25327ac0cc
- 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.
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?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);
|
||
}
|
||
}
|