From 1f6f77a34f32d72979c023f2b53c49fc2693a939 Mon Sep 17 00:00:00 2001 From: Lemuel Marquez Date: Wed, 24 Mar 2021 20:17:50 -0600 Subject: [PATCH] por si las moscas --- server/db/actualizar.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/server/db/actualizar.js b/server/db/actualizar.js index 3c87181..e0a0926 100644 --- a/server/db/actualizar.js +++ b/server/db/actualizar.js @@ -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);