From 8130675d587c5d57f0f4c5e636cbb8b258c65d66 Mon Sep 17 00:00:00 2001 From: Ignacio Otero <nacho.ote@gmail.com> Date: Tue, 19 Oct 2021 10:42:57 -0300 Subject: [PATCH] =?UTF-8?q?Arreglo=20de=20sincronizaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 ++-- src/Services/ParameterService.ts | 39 ++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 2f26ed0..26702f2 100644 --- a/.env +++ b/.env @@ -2,5 +2,5 @@ PORT=8000 INSTANCE=PROD HOST=localhost USER=root -PASSWORD=rootroot -DB=parameter_database \ No newline at end of file +PASSWORD=mysql +DB=repp_users \ No newline at end of file diff --git a/src/Services/ParameterService.ts b/src/Services/ParameterService.ts index e76ec61..8bb2070 100644 --- a/src/Services/ParameterService.ts +++ b/src/Services/ParameterService.ts @@ -227,17 +227,36 @@ const updateDefaultWeight = async (parameter: DefaultWeightDTO): Promise<void> = const updatePercentage = async (params: DefaultExtraDataDTO[], total: number): Promise<void> => { if (total === 100) { - params.forEach(async (param: DefaultExtraDataDTO) => { - await DefaultExtraData.update( - { value: param.value }, - { - where: { - id: param.id, - }, + // No se mete en un for porque hay problemas con el await + await DefaultExtraData.update( + { value: params[0].value }, + { + where: { + id: params[0].id, }, - ).catch((err) => { - throw err; - }); + }, + ).catch((err) => { + throw err; + }); + await DefaultExtraData.update( + { value: params[1].value }, + { + where: { + id: params[1].id, + }, + }, + ).catch((err) => { + throw err; + }); + await DefaultExtraData.update( + { value: params[2].value }, + { + where: { + id: params[2].id, + }, + }, + ).catch((err) => { + throw err; }); } else { throw new Error('These percentages must add up to 100'); -- GitLab