Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agregar filtros a actividades por fechas #118

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions modules/actividades/controllers/consultarActividades.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ const getImageFolder = require('../../../util/getImageFolder');

const getRodadas = async (request, response) => {
try {
const fechaConsulta = new Date(); // Fecha de consulta actual
fechaConsulta.setUTCHours(0, 0, 0, 0)

const rodadas = await Rodada.find({
"informacion.estado": true
}).populate('ruta');
"informacion.estado": true,
"informacion.fecha": { $gte: fechaConsulta }
}).sort({ "informacion.fecha": 1 }).populate('ruta'); // Ordenar por fecha ascendente

request.rodadas = rodadas.map(rodada => rodada.informacion).flat();

Expand All @@ -36,12 +40,15 @@ const getRodadas = async (request, response) => {
}
};


const getEventos = async (request, response) => {
try {
const fechaConsulta = new Date(); // Fecha de consulta actual
fechaConsulta.setUTCHours(0, 0, 0, 0)

const eventos = await Evento.find({
"informacion.estado": true
});
"informacion.estado": true,
"informacion.fecha": { $gte: fechaConsulta }
}).sort({ "informacion.fecha": 1 }); // Ordenar por fecha ascendente

request.eventos = eventos.map(evento => evento.informacion).flat();

Expand All @@ -53,7 +60,6 @@ const getEventos = async (request, response) => {
evento.informacion = informacionImagen[index];
});


response.status(200).json({
eventos: eventos,
permisos: request.permisos
Expand All @@ -69,9 +75,13 @@ const getEventos = async (request, response) => {

const getTalleres = async (request, response) => {
try {
const fechaConsulta = new Date(); // Fecha de consulta actual
fechaConsulta.setUTCHours(0, 0, 0, 0)

const talleres = await Taller.find({
"informacion.estado": true
});
"informacion.estado": true,
"informacion.fecha": { $gte: fechaConsulta }
}).sort({ "informacion.fecha": 1 }); // Ordenar por fecha ascendente

request.talleres = talleres.map(taller => taller.informacion).flat();

Expand All @@ -93,7 +103,7 @@ const getTalleres = async (request, response) => {
error
});
}
}
};

const getActividad = async (request, response) => {
const id = request.query.id;
Expand Down
Loading