listo
This commit is contained in:
@@ -9,6 +9,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
let path = `csv/${year}_cuestionario_programa.csv`;
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -22,7 +23,6 @@ const get = async (body) => {
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
let csvString = '';
|
||||
let path = `csv/${year}_cuestionarios_programa.csv`;
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
@@ -47,10 +47,7 @@ const get = async (body) => {
|
||||
} catch (err) {}
|
||||
csvString = convertArrayToCSV(data);
|
||||
fs.appendFile(path, csvString, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw new Error('hubo un problema al crear el archivo csv.');
|
||||
}
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
|
||||
@@ -17,7 +17,6 @@ const nuevo = async (body) => {
|
||||
retroalimentacion += body.retroalimentacion[i];
|
||||
if (i < body.retroalimentacion.length - 1) retroalimentacion += ',';
|
||||
}
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
@@ -59,15 +58,13 @@ const nuevo = async (body) => {
|
||||
throw new Error('Este Servicio Social fue cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ idCuestionarioPrograma: res.idCuestionarioPrograma },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
)
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => {
|
||||
return { message: `Se guradaron tus respuestas correctamente. ${res}` };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user