por si las moscas
This commit is contained in:
+18
-14
@@ -5,27 +5,31 @@ const lastYear = moment('2021-01-31');
|
||||
const fechaLiberacion = async () => {
|
||||
Servicio.findAll({ where: { idStatus: 6 } })
|
||||
.then(async (res) => {
|
||||
let contador = [0, 0];
|
||||
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`
|
||||
);
|
||||
// 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`
|
||||
// );
|
||||
contador[0]++;
|
||||
} 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`
|
||||
);
|
||||
// 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`
|
||||
// );
|
||||
contador[1]++;
|
||||
}
|
||||
}
|
||||
console.log(contador);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
Reference in New Issue
Block a user