listo para actualizar a casos especiales en producción
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
const moment = require('moment');
|
||||
const Servicio = require('./tablas/Servicio');
|
||||
const lastYear = moment('2021-01-31');
|
||||
|
||||
const fechaLiberacion = async () => {
|
||||
Servicio.findAll({ where: { idStatus: 6 } })
|
||||
.then(async (res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
let lastUpdate = moment(res[i].updatedAt);
|
||||
|
||||
if (lastUpdate <= lastYear) {
|
||||
// await Servicio.update(
|
||||
// { fechaLiberacion: lastYear },
|
||||
// { where: { idServicio: res[i].idServicio } }
|
||||
// );
|
||||
console.log(
|
||||
`El servicio con id ${res[i].idServicio} fue actualizado el ${res[i].updatedAt} año pasado`
|
||||
);
|
||||
} else {
|
||||
// await Servicio.update(
|
||||
// { fechaLiberacion: lastUpdate },
|
||||
// { where: { idServicio: res[i].idServicio } }
|
||||
// );
|
||||
console.log(
|
||||
`El servicio con id ${res[i].idServicio} fue actualizado el ${res[i].updatedAt} siguiente año`
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
fechaLiberacion();
|
||||
|
||||
/*
|
||||
ALTER TABLE servicio ADD fechaLiberacion datetime
|
||||
|
||||
Pull al back
|
||||
Instalar tabla casos especiales/usuario
|
||||
agrear campo fecha liberacion a la tabla servicio
|
||||
modificar campo carpeta
|
||||
asignar fecha de liberacipon a servicios liberados
|
||||
*/
|
||||
+18
-3
@@ -80,7 +80,7 @@ const sync = async () => {
|
||||
};
|
||||
|
||||
const dataTipoUsuario = async () => {
|
||||
const data = ['admin', 'responsable', 'alumno', 'casoEspecial'];
|
||||
const data = ['admin', 'responsable', 'alumno', 'caso especial'];
|
||||
|
||||
console.log('\nPaso 3) Instalando data de TipoUsuario.'.bold.blue);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
@@ -132,7 +132,7 @@ const dataResponsableCasoEspecial = async () => {
|
||||
await Usuario.create({
|
||||
usuario: process.env.CASOS_ESPECIALES,
|
||||
password: encriptar.encriptar(process.env.CASOS_ESPECIALES_PASSWORD),
|
||||
nombre: 'Marce',
|
||||
nombre: 'Marcela Martínez Rangel',
|
||||
idTipoUsuario: 4,
|
||||
activo: true,
|
||||
});
|
||||
@@ -152,4 +152,19 @@ const exe = async () => {
|
||||
process.exit();
|
||||
};
|
||||
|
||||
exe();
|
||||
// exe();
|
||||
|
||||
const exeCasosEspeciales = async () => {
|
||||
await CasoEspecial.sync();
|
||||
console.log('La tabla CasoEspecial se instalo correctamente.'.magenta);
|
||||
|
||||
await dataResponsableCasoEspecial();
|
||||
|
||||
console.log(
|
||||
'\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green
|
||||
);
|
||||
|
||||
process.exit();
|
||||
};
|
||||
|
||||
exeCasosEspeciales();
|
||||
|
||||
@@ -31,60 +31,44 @@ app.post(
|
||||
}
|
||||
);
|
||||
|
||||
app.get(
|
||||
`${route}/servicios_especiales`,
|
||||
// verificaToken,
|
||||
(req, res) => {
|
||||
return serviciosEspeciales(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}
|
||||
);
|
||||
app.get(`${route}/servicios_especiales`, verificaToken, (req, res) => {
|
||||
return serviciosEspeciales(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.get(
|
||||
`${route}`,
|
||||
// verificaToken,
|
||||
(req, res) => {
|
||||
return casoEspecial(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}
|
||||
);
|
||||
app.get(`${route}`, verificaToken, (req, res) => {
|
||||
return casoEspecial(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.put(
|
||||
`${route}/liberacion`,
|
||||
// verificaToken,
|
||||
(req, res) => {
|
||||
return liberacion(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}
|
||||
);
|
||||
app.put(`${route}/liberacion`, verificaToken, (req, res) => {
|
||||
return liberacion(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.put(
|
||||
`${route}/update`,
|
||||
// verificaToken,
|
||||
(req, res) => {
|
||||
return update(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}
|
||||
);
|
||||
app.put(`${route}/update`, verificaToken, (req, res) => {
|
||||
return update(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user