IPC rango y sort
This commit is contained in:
@ -27,6 +27,7 @@ class IPC
|
|||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
$ipc = $this->moneyService->getIPC($from, $to);
|
$ipc = $this->moneyService->getIPC($from, $to);
|
||||||
$ipcs[$dateKey] = $ipc;
|
$ipcs[$dateKey] = $ipc;
|
||||||
|
ksort($ipcs);
|
||||||
$this->redisService->set($this->redisKey, json_encode($ipcs), 60 * 60 * 24 * 30);
|
$this->redisService->set($this->redisKey, json_encode($ipcs), 60 * 60 * 24 * 30);
|
||||||
}
|
}
|
||||||
return $ipcs[$dateKey];
|
return $ipcs[$dateKey];
|
||||||
|
@ -22,6 +22,7 @@ class UF
|
|||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
$uf = $this->moneyService->getUF($date);
|
$uf = $this->moneyService->getUF($date);
|
||||||
$ufs[$date->format('Y-m-d')] = $uf;
|
$ufs[$date->format('Y-m-d')] = $uf;
|
||||||
|
ksort($ufs);
|
||||||
$this->redisService->set($this->redisKey, json_encode($ufs), 60 * 60 * 24 * 30);
|
$this->redisService->set($this->redisKey, json_encode($ufs), 60 * 60 * 24 * 30);
|
||||||
}
|
}
|
||||||
return $uf;
|
return $uf;
|
||||||
|
@ -17,16 +17,20 @@ class IPC extends Command
|
|||||||
$lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M'));
|
$lastMonth = (new DateTimeImmutable())->sub(new DateInterval('P1M'));
|
||||||
$endLastYear = (new DateTimeImmutable())->sub(new DateInterval('P1Y'));
|
$endLastYear = (new DateTimeImmutable())->sub(new DateInterval('P1Y'));
|
||||||
$uri = '/api/money/ipc';
|
$uri = '/api/money/ipc';
|
||||||
$data = [
|
$current = new DateTimeImmutable($lastMonth->format('Y-m-d'));
|
||||||
'start' => $endLastYear->format('Y-12-1'),
|
while ($current->diff($endLastYear)->days > 30) {
|
||||||
'end' => $lastMonth->format('Y-m-1')
|
$data = [
|
||||||
];
|
'start' => $endLastYear->format('Y-12-1'),
|
||||||
$output->writeln("POST {$uri}");
|
'end' => $current->format('Y-m-1')
|
||||||
$response = $this->client->post($uri, [
|
];
|
||||||
'body' => http_build_query($data),
|
$output->writeln("POST {$uri}");
|
||||||
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded']
|
$response = $this->client->post($uri, [
|
||||||
]);
|
'body' => http_build_query($data),
|
||||||
$output->writeln("Response Code: {$response->getStatusCode()}");
|
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded']
|
||||||
|
]);
|
||||||
|
$output->writeln("Response Code: {$response->getStatusCode()}");
|
||||||
|
$current = $current->sub(new DateInterval('P1M'));
|
||||||
|
}
|
||||||
return Console\Command\Command::SUCCESS;
|
return Console\Command\Command::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user