From ecae3147d484015990c6838cc17702b9f439e509 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 3 Oct 2025 12:09:54 -0300 Subject: [PATCH] Get values when 0 --- app/src/Controller/API/Money.php | 2 +- app/src/Service/IPC.php | 2 +- app/src/Service/UF.php | 8 ++++++-- app/src/Service/USD.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/Controller/API/Money.php b/app/src/Controller/API/Money.php index a13d14a..ea74f10 100644 --- a/app/src/Controller/API/Money.php +++ b/app/src/Controller/API/Money.php @@ -53,7 +53,7 @@ class Money } try { $this->data[$provider] = (array) $this->fetchRedis($redisService, $redisKey); - if (!isset($this->data[$provider][$date->format('Y-m-d')])) { + if (!isset($this->data[$provider][$date->format('Y-m-d')]) or $this->data[$provider][$date->format('Y-m-d')] === 0) { throw new EmptyRedis($redisKey); } } catch (EmptyRedis) { diff --git a/app/src/Service/IPC.php b/app/src/Service/IPC.php index b75398d..b8a51b2 100644 --- a/app/src/Service/IPC.php +++ b/app/src/Service/IPC.php @@ -21,7 +21,7 @@ class IPC $ipcs = []; try { $ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); - if (!isset($ipcs[$dateKey])) { + if (!isset($ipcs[$dateKey]) or $ipcs[$dateKey] === 0) { throw new EmptyRedis($this->redisKey); } } catch (EmptyRedis) { diff --git a/app/src/Service/UF.php b/app/src/Service/UF.php index 58d80b0..c99771f 100644 --- a/app/src/Service/UF.php +++ b/app/src/Service/UF.php @@ -22,7 +22,7 @@ class UF if ($date === null) { $date = new DateTimeImmutable(); } - if ($date->diff($today)->days < 0) { + if ($date->diff($today)->invert === 1) { return 0.0; } /** @@ -32,7 +32,7 @@ class UF */ try { $ufs = $this->getRedisUFs(); - if (!isset($ufs[$date->format('Y-m-d')])) { + if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) { throw new EmptyRedis($this->redisKey); } return $ufs[$date->format('Y-m-d')]; @@ -54,12 +54,16 @@ class UF } public function updateMany(array $dates): array { + $today = new DateTimeImmutable(); $ufs = []; try { $ufs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); } catch (EmptyRedis) {} $updated = []; foreach ($dates as $date) { + if ($date->diff($today)->invert === 1) { + continue; + } if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) { $uf = $this->moneyService->getUF($date); if ($uf === 0.0) { diff --git a/app/src/Service/USD.php b/app/src/Service/USD.php index edfeed5..21f343c 100644 --- a/app/src/Service/USD.php +++ b/app/src/Service/USD.php @@ -19,7 +19,7 @@ class USD $usds = []; try { $usds = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); - if (!isset($usds[$date->format('Y-m-d')])) { + if (!isset($usds[$date->format('Y-m-d')]) or $usds[$date->format('Y-m-d')] === 0) { throw new EmptyRedis($this->redisKey); } $usd = $usds[$date->format('Y-m-d')];