From: xangelo Date: Fri, 27 May 2022 14:48:03 +0000 (-0400) Subject: bug: things were scheduling out to 2074 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=1c36196a3d546d25672802e9da128d1750fa3259;p=browser-rts.git 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. --- 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');