Accelerar listado ventas
This commit is contained in:
@ -74,6 +74,32 @@ class Ventas extends Controller
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function getMany(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta $service): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'ventas' => []
|
||||
];
|
||||
$ventas = explode(',', $body['ventas']);
|
||||
foreach ($ventas as $venta_id) {
|
||||
$redisKey = "venta:{$venta_id}";
|
||||
try {
|
||||
$venta = $this->fetchRedis($redisService, $redisKey);
|
||||
$output['ventas'] []= $venta;
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$venta = $service->getById($venta_id);
|
||||
$output['ventas'] []= $venta;
|
||||
$this->saveRedis($redisService, $redisKey, $venta);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->notice($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function porFirmar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService, Service\Redis $redisService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
|
Reference in New Issue
Block a user