Skip to content

Commit

Permalink
feat(HUDS): Agregar filtro de descargas pendientes
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-bravo authored and negro89 committed May 12, 2023
1 parent 4706a53 commit 81f0f45
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/huds/export-huds/exportHuds.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ export const ExportHudsRouter = express.Router();
ExportHudsRouter.use(Auth.authenticate());

ExportHudsRouter.get('/export', async (req, res, next) => {
const query = {
const query: any = {
'user.usuario.id': req.query.id,
status: { $in: ['pending', 'completed'] }
};
if (req.query.fechaDesde && req.query.fechaHasta) {
query.createdAt = { $gte: new Date(req.query.fechaDesde), $lte: new Date(req.query.fechaHasta) };
} else {
if (req.query.fechaDesde) {
query.createdAt = { $gte: new Date(req.query.fechaDesde) };
}
if (req.query.fechaHasta) {
query.createdAt = { $lte: new Date(req.query.fechaHasta) };
}
}
const pending = await ExportHudsModel.find(query).sort({ createdAt: -1 });
res.json(pending);
});
Expand Down

0 comments on commit 81f0f45

Please sign in to comment.