From 1c36196a3d546d25672802e9da128d1750fa3259 Mon Sep 17 00:00:00 2001 From: xangelo Date: Fri, 27 May 2022 10:48:03 -0400 Subject: [PATCH] bug: things were scheduling out to 2074 Instead of passing a diff between now and the due date, we were passing the due date to delay jobs. As a result it was scheduling it way further that it should be. --- src/api.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api.ts b/src/api.ts index 9fab0f4..50d4f06 100644 --- a/src/api.ts +++ b/src/api.ts @@ -274,7 +274,7 @@ server.post<{ const queueData = await cityRepo.buildBuilding(building, amount, city); - construction.trigger(queueData, { delay: queueData.due }); + construction.trigger(queueData, { delay: queueData.due - Date.now() }); }, 'reload-construction-queue'); server.post<{ @@ -288,7 +288,8 @@ server.post<{ const acct = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token); const city = await cityRepo.getUsersCity(acct.id); - const amount = parseInt(req.body.amount, 10); + const amount = parseInt(req.body.amount, 10) || 0; + console.log('request amount?!', amount); if(amount < 1) { throw new BadInputError('Please specify an amount > 0', ERROR_CODE.INVALID_AMOUNT); } @@ -299,7 +300,7 @@ server.post<{ } const queueData = await cityRepo.train(unit, amount, city); - unitTraining.trigger(queueData, { delay: queueData.due }); + unitTraining.trigger(queueData, { delay: queueData.due - Date.now() }); }, 'reload-unit-training'); -- 2.25.1