actualizacion en contar las asistencias

This commit is contained in:
DanielRamirezGe
2019-10-15 17:10:57 -05:00
parent 5053ab788c
commit 261362c37e
+25 -7
View File
@@ -9,15 +9,33 @@ app.get('/cupo', async(req, res) => {
res.status(400).json({ err: true });
return;
}
await results.forEach(element => {
if (element.idConferencia == 7)
arr.push([element.nombre, 'ilimitado', 100000 - element.capacidad]);
else
arr.push([element.nombre, 150, 150 - element.capacidad]);
await results.forEach(async element => {
if (element.idConferencia == 7) {
await connection.query(`select count(asistencia) as asis from asistencia where idConferencia=7 and asistencia=1;`,
(e, r, f) => {
if (e) {
res.status(400).json({ err: true, msj: "error al contar" });
return;
}
arr.push([element.nombre, 'ilimitado', 100000 - element.capacidad, r[0].asis]);
})
} else {
await connection.query(`select count(asistencia) as asis from asistencia where idConferencia=${element.idConferencia} and asistencia=1;`,
(e, r, f) => {
if (e) {
res.status(400).json({ err: true, msj: "error al contar" });
return;
}
arr.push([element.nombre, 150, 150 - element.capacidad, r[0].asis]);
if (element.idConferencia == 13) {
res.status(200).json(arr);
return;
}
})
}
});
res.status(200).json(arr);
return;
});
});