From c4e3645145f0f05df1e7eccdc1352b85b46e0133 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Sat, 12 Apr 2025 20:27:06 -0500 Subject: [PATCH] wip --- app/Models/CurrencyRate.php | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/Models/CurrencyRate.php b/app/Models/CurrencyRate.php index 93f884e..6976f42 100644 --- a/app/Models/CurrencyRate.php +++ b/app/Models/CurrencyRate.php @@ -10,6 +10,7 @@ use Carbon\CarbonPeriod; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Log; use Investbrain\Frankfurter\Frankfurter; class CurrencyRate extends Model @@ -156,34 +157,33 @@ class CurrencyRate extends Model $rates = array_merge($rates, Arr::get($chunkRates, 'rates', [])); } - dump('done with frankf'); + dump('done with frankf', count($rates)); // loop through each date $updates = []; foreach ($period as $date) { - try { - $lookupDate = self::getNearestPastDate($date, $rates); + $lookupDate = self::getNearestPastDate($date, $rates); - if (is_null($lookupDate)) { - continue; - } + Log::warn($lookupDate, isset($rates[$lookupDate->toDateString()])); - // loop through each rate - foreach ($rates[$lookupDate->toDateString()] as $curr => $rate) { - - // add to updates - $updates[] = [ - 'currency' => $curr, - 'date' => $date->toDateString(), - 'rate' => $rate, - 'updated_at' => now()->toDateTimeString(), - 'created_at' => now()->toDateTimeString(), - ]; - } - } catch (\Throwable $e) { - dump($e->getMessage()); + if (is_null($lookupDate)) { + continue; } + + // loop through each rate + foreach ($rates[$lookupDate->toDateString()] as $curr => $rate) { + + // add to updates + $updates[] = [ + 'currency' => $curr, + 'date' => $date->toDateString(), + 'rate' => $rate, + 'updated_at' => now()->toDateTimeString(), + 'created_at' => now()->toDateTimeString(), + ]; + } + } dump('inserting');