IPC acumulado desde cli

This commit is contained in:
2023-11-30 00:06:21 -03:00
parent 68821fb0d3
commit d0a85b2149
3 changed files with 6 additions and 5 deletions

View File

@ -92,7 +92,7 @@ class Money
if ($end > $now) { if ($end > $now) {
return $this->withJson($response, $output); 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['date_string'] = $dateKey;
$output['ipc'] = $ipcService->get($start, $end); $output['ipc'] = $ipcService->get($start, $end);
return $this->withJson($response, $output); return $this->withJson($response, $output);

View File

@ -17,7 +17,7 @@ class IPC
if ($to > $now) { if ($to > $now) {
return 0; return 0;
} }
$dateKey = "{$from->format('Y-m')}-{$to->format('Y-m')}"; $dateKey = "{$from->format('Y-m')}|{$to->format('Y-m')}";
$ipcs = []; $ipcs = [];
try { try {
$ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY); $ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);

View File

@ -15,10 +15,11 @@ class IPC extends Command
{ {
$this->logger->debug("Running {$this->getName()}"); $this->logger->debug("Running {$this->getName()}");
$lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M')); $lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M'));
$uri = '/api/money'; $endLastYear = (new DateTimeImmutable())->sub(new DateInterval('P1Y'));
$uri = '/api/money/ipc';
$data = [ $data = [
'provider' => 'ipc', 'start' => $endLastYear->format('Y-12-1'),
'fecha' => $lastMonth->format('Y-m-1') 'end' => $lastMonth->format('Y-m-1')
]; ];
$output->writeln("POST {$uri}"); $output->writeln("POST {$uri}");
$response = $this->client->post($uri, [ $response = $this->client->post($uri, [