Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 98e5159f2f | |||
| f86c4d4f2a | |||
| ffb2a1d64a | |||
| 4660214cd7 | |||
| 8e74802de7 |
@@ -450,15 +450,35 @@ export class PrestamoService {
|
||||
if (filtros.pagina) {
|
||||
options.take = 25;
|
||||
options.skip = (parseInt(filtros.pagina) - 1) * 25;
|
||||
return this.fullInformacionPrestamoView
|
||||
.findAndCount(options)
|
||||
.then((infoPrestamos) => {
|
||||
const prestamos: Prestamo[] = [];
|
||||
|
||||
for (let i = 0; i < infoPrestamos[0].length; i++)
|
||||
prestamos.push(this.fullViewToPrestamo(infoPrestamos[0][i]));
|
||||
return [prestamos, infoPrestamos[1]];
|
||||
});
|
||||
const activoTrue =
|
||||
(typeof filtros.activo === 'boolean' && filtros.activo) ||
|
||||
(typeof filtros.activo === 'string' && filtros.activo === 'true');
|
||||
const canUseLightCount =
|
||||
activoTrue && !filtros.usuario && !filtros.id_tipo_usuario;
|
||||
|
||||
if (canUseLightCount) {
|
||||
const { usuario: _u, id_tipo_usuario: _tu, ...countWhere } =
|
||||
busqueda;
|
||||
const [rows, total] = await Promise.all([
|
||||
this.fullInformacionPrestamoView.find(options),
|
||||
this.informacionPrestamoView.count({
|
||||
where: countWhere as FindOptionsWhere<InformacionPrestamoView>,
|
||||
}),
|
||||
]);
|
||||
const prestamos = rows.map((row) => this.fullViewToPrestamo(row));
|
||||
|
||||
return [prestamos, total];
|
||||
}
|
||||
|
||||
const infoPrestamos = await this.fullInformacionPrestamoView.findAndCount(
|
||||
options,
|
||||
);
|
||||
const prestamos: Prestamo[] = [];
|
||||
|
||||
for (let i = 0; i < infoPrestamos[0].length; i++)
|
||||
prestamos.push(this.fullViewToPrestamo(infoPrestamos[0][i]));
|
||||
return [prestamos, infoPrestamos[1]];
|
||||
}
|
||||
options.order = { id_institucion: 'ASC', id_prestamo: 'ASC' };
|
||||
return this.fullInformacionPrestamoView.find(options);
|
||||
|
||||
Reference in New Issue
Block a user