From d0a85b2149e7661bf08d651f6d97c0efec4135ec Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 30 Nov 2023 00:06:21 -0300 Subject: [PATCH] IPC acumulado desde cli --- app/src/Controller/API/Money.php | 2 +- app/src/Service/IPC.php | 2 +- cli/src/Command/Money/IPC.php | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/Controller/API/Money.php b/app/src/Controller/API/Money.php index 28a0b14..61a8ae0 100644 --- a/app/src/Controller/API/Money.php +++ b/app/src/Controller/API/Money.php @@ -92,7 +92,7 @@ class Money if ($end > $now) { return $this->withJson($response, $output); } - $dateKey = "{$start->format('Y-m')}-{$end->format('Y-m')}"; + $dateKey = "{$start->format('Y-m')}|{$end->format('Y-m')}"; $output['date_string'] = $dateKey; $output['ipc'] = $ipcService->get($start, $end); return $this->withJson($response, $output); diff --git a/app/src/Service/IPC.php b/app/src/Service/IPC.php index fcba1b4..044b4ff 100644 --- a/app/src/Service/IPC.php +++ b/app/src/Service/IPC.php @@ -17,7 +17,7 @@ class IPC if ($to > $now) { return 0; } - $dateKey = "{$from->format('Y-m')}-{$to->format('Y-m')}"; + $dateKey = "{$from->format('Y-m')}|{$to->format('Y-m')}"; $ipcs = []; try { $ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); diff --git a/cli/src/Command/Money/IPC.php b/cli/src/Command/Money/IPC.php index 081dd36..92e8d86 100644 --- a/cli/src/Command/Money/IPC.php +++ b/cli/src/Command/Money/IPC.php @@ -15,10 +15,11 @@ class IPC extends Command { $this->logger->debug("Running {$this->getName()}"); $lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M')); - $uri = '/api/money'; + $endLastYear = (new DateTimeImmutable())->sub(new DateInterval('P1Y')); + $uri = '/api/money/ipc'; $data = [ - 'provider' => 'ipc', - 'fecha' => $lastMonth->format('Y-m-1') + 'start' => $endLastYear->format('Y-12-1'), + 'end' => $lastMonth->format('Y-m-1') ]; $output->writeln("POST {$uri}"); $response = $this->client->post($uri, [