Integrate FetchGoldRates and MergeCurrencyAndGoldRates jobs in CurrencyController

- Added the `FetchGoldRates` job to retrieve gold rates and the `MergeCurrencyAndGoldRates` job to combine currency and gold rates.
- Updated the `getCurrentRates` method to read from a new JSON file `merged/rates.json` instead of the previous `currency/today.json`.
- Commented out the synchronous dispatch of the fetching jobs for future implementation.

This commit enhances the CurrencyController's functionality by preparing it for integrated financial data management.
This commit is contained in:
Ümit Tunç
2025-01-17 22:59:11 +03:00
parent 11106995d4
commit aa03ed3706
+9 -4
View File
@@ -3,6 +3,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Jobs\FetchCurrencyRates; use App\Jobs\FetchCurrencyRates;
use App\Jobs\FetchGoldRates;
use App\Jobs\MergeCurrencyAndGoldRates;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
class CurrencyController extends Controller class CurrencyController extends Controller
@@ -10,12 +12,15 @@ class CurrencyController extends Controller
public function getCurrentRates() public function getCurrentRates()
{ {
// Job'ı çalıştır // Job'ı çalıştır
// $data = FetchCurrencyRates::dispatchSync(); /*
FetchCurrencyRates::dispatchSync();
FetchGoldRates::dispatchSync();
MergeCurrencyAndGoldRates::dispatchSync();
*/
// JSON dosyasından oku // JSON dosyasından oku
if (Storage::exists('currency/today.json')) { if (Storage::exists('merged/rates.json')) {
return response()->json( return response()->json(
json_decode(Storage::get('currency/today.json'), true) json_decode(Storage::get('merged/rates.json'), true)
); );
} }