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 439191008a - Show all commits

View File

@@ -117,10 +117,13 @@ const findAndNotifyNextWinner = async () => {
let winesLeft = await PreLotteryWine.find();
if (winnersLeft.length > 1) {
console.log("multiple winners left, choose next in line")
nextWinner = winnersLeft[0]; // multiple winners left, choose next in line
} else if (winnersLeft.length == 1 && winesLeft.length > 1) {
console.log("one winner left, but multiple wines")
nextWinner = winnersLeft[0] // one winner left, but multiple wines
} else if (winnersLeft.length == 1 && winesLeft.length == 1) {
console.log("one winner and one wine left, choose for user")
nextWinner = winnersLeft[0] // one winner and one wine left, choose for user
wine = winesLeft[0]
return chooseLastWineForUser(nextWinner, wine);