Optimizacion de queries a cargar de una sola vez
This commit is contained in:
@ -168,18 +168,10 @@ class Contracts
|
||||
if (is_string($unit_ids)) {
|
||||
$unit_ids = json_decode($input['unidad_ids'], true);
|
||||
}
|
||||
foreach ($unit_ids as $unit_id) {
|
||||
try {
|
||||
$unit = $unitRepository->fetchById($unit_id);
|
||||
$contractService->getById($contract_id);
|
||||
$promotions = $promotionRepository->fetchByContractAndUnit($contract_id, $unit->id);
|
||||
$output['unidades'] []= [
|
||||
'id' => $unit->id,
|
||||
'promotions' => $promotions
|
||||
];
|
||||
} catch (ServiceAction\Read | Implement\Exception\EmptyResult $exception) {
|
||||
$logger->debug($exception);
|
||||
}
|
||||
try {
|
||||
$output['unidades'] = $promotionRepository->fetchByContractAndUnits($contract_id, $unit_ids);
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
$logger->debug($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user