Bug/51 - Last winner is not automatically receiving the last wine! #52

Merged
KevinMidboe merged 4 commits from bug/51 into master 2020-10-11 20:30:02 +00:00
Showing only changes of commit 795f110e1b - Show all commits

View File

@@ -95,15 +95,19 @@ const registerWinnerSelection = async (req, res) => {
})) }))
}; };
const chooseLastWineForUser = (winner, prelotteryWine) => { const chooseLastWineForUser = (winner, preLotteryWine) => {
let date = new Date(); let date = new Date();
date.setHours(5, 0, 0, 0); date.setHours(5, 0, 0, 0);
return _wineFunctions.findSaveWine(preLotteryWine) return _wineFunctions.findSaveWine(preLotteryWine)
.then(wonWine => _personFunctions.findSavePerson(winner, wonWine, date)) .then(wonWine => _personFunctions.findSavePerson(winner, wonWine, date))
.then(() => prelotteryWine.delete()) .then(() => preLotteryWine.delete())
.then(() => Message.sendLastWinnerMessage(winner, preLotteryWine)) .then(() => Message.sendLastWinnerMessage(winner, preLotteryWine))
.then(() => winner.delete()); .then(() => winner.delete())
.catch(err => {
console.log("Error thrown from chooseLastWineForUser: " + err);
throw err;
})
} }
const findAndNotifyNextWinner = async () => { const findAndNotifyNextWinner = async () => {