validar cuestionario y comentar el envio de correos de gmail para evitar errores
This commit is contained in:
@@ -12,9 +12,6 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
|
||||
|
||||
|
||||
|
||||
const getOld = async (body) => {
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
@@ -84,118 +81,31 @@ const getOld = async (body) => {
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
const get = async (body) => {
|
||||
console.log(body);
|
||||
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
console.log(year);
|
||||
console.log(year);
|
||||
|
||||
|
||||
/*
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
{
|
||||
model: CuestionarioAlumno2,
|
||||
where: { idCuestionarioAlumno: { [Op.not]: null } },
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* return CuestionarioAlumno2.findAll({
|
||||
return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
// order: [['createdAt', 'ASC']], // Descomentar si se requiere ordenamiento
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log('segunda parte', res);
|
||||
|
||||
console.log("segunda parte",res);
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({ ...res})
|
||||
|
||||
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioAlumno: res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
sexo: res[i].CuestionarioAlumno.sexo,
|
||||
edad: res[i].CuestionarioAlumno.edad,
|
||||
servicioMedico: res[i].CuestionarioAlumno.servicioMedico,
|
||||
p1: res[i].CuestionarioAlumno.p1,
|
||||
p2: res[i].CuestionarioAlumno.p2,
|
||||
p3: res[i].CuestionarioAlumno.p3,
|
||||
p4: res[i].CuestionarioAlumno.p4,
|
||||
p5: res[i].CuestionarioAlumno.p5,
|
||||
p6: res[i].CuestionarioAlumno.p6,
|
||||
p7: res[i].CuestionarioAlumno.p7,
|
||||
p8: res[i].CuestionarioAlumno.p8,
|
||||
p9: res[i].CuestionarioAlumno.p9,
|
||||
p10: res[i].CuestionarioAlumno.p10,
|
||||
p11: res[i].CuestionarioAlumno.p11,
|
||||
p12: res[i].CuestionarioAlumno.p12,
|
||||
p13: res[i].CuestionarioAlumno.p13,
|
||||
p14: res[i].CuestionarioAlumno.p14,
|
||||
p15: res[i].CuestionarioAlumno.p15,
|
||||
p16: res[i].CuestionarioAlumno.p16,
|
||||
p17: res[i].CuestionarioAlumno.p17,
|
||||
p18: res[i].CuestionarioAlumno.p18,
|
||||
p19: res[i].CuestionarioAlumno.p19,
|
||||
p20: res[i].CuestionarioAlumno.p20,
|
||||
p21: res[i].CuestionarioAlumno.p21,
|
||||
p22: res[i].CuestionarioAlumno.p22,
|
||||
p23: res[i].CuestionarioAlumno.p23,
|
||||
p24: res[i].CuestionarioAlumno.p24,
|
||||
p25: res[i].CuestionarioAlumno.p25,
|
||||
p26: res[i].CuestionarioAlumno.p26,
|
||||
p27: res[i].CuestionarioAlumno.p27,
|
||||
p28: res[i].CuestionarioAlumno.p28,
|
||||
p29: res[i].CuestionarioAlumno.p29,
|
||||
p30: res[i].CuestionarioAlumno.p30,
|
||||
createdAt: res[i].CuestionarioAlumno.createdAt,
|
||||
});
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}; */
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
const row = res[i].get({ plain: true });
|
||||
data.push({
|
||||
idCuestionarioAlumno2: row.idCuestionarioAlumno2,
|
||||
@@ -208,16 +118,13 @@ return CuestionarioAlumno2.findAll({
|
||||
});
|
||||
} */
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}
|
||||
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
|
||||
@@ -179,7 +179,7 @@ const nuevo = async (body) => {
|
||||
); */
|
||||
|
||||
|
||||
// body = validar.validarCuestionarioAlumno2(body);
|
||||
body = validar.validarCuestionarioAlumno2(body);
|
||||
|
||||
|
||||
// pasar preguntas de array a string
|
||||
|
||||
@@ -88,6 +88,8 @@ const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
body = validar.validarCuestionarioAlumno2(body);
|
||||
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
|
||||
@@ -6,12 +6,18 @@ const send = require('gmail-send')({
|
||||
});
|
||||
|
||||
const gmail = (subject, to, text) => {
|
||||
/*
|
||||
return new Promise((resolve, reject) => {
|
||||
send({ subject, to, text }, (error, result, fullResult) => {
|
||||
if (error) reject(error);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
return "envio de correo"
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = gmail;
|
||||
|
||||
@@ -261,4 +261,8 @@ module.exports = {
|
||||
validarNumero,
|
||||
validarObjetoVacio,
|
||||
validarPreTermino,
|
||||
|
||||
validarCuestionarioAlumno2,
|
||||
validarCuestionarioPrograma2
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user