forked from rDrama/rDrama
1
0
Fork 0

cron.py bugs: missing import; lottery edge case

master
Snakes 2022-07-21 14:28:52 -04:00
parent 0fe1e57ecd
commit be1023f734
Signed by: Snakes
GPG Key ID: E745A82778055C7E
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
from files.cli import g, app, db_session
import click
from files.helpers.const import *
from files.classes import *
import files.helpers.lottery as lottery
import files.helpers.offsitementions as offsitementions

View File

@ -38,6 +38,10 @@ def end_lottery_session():
for _ in range(user.currently_held_lottery_tickets):
raffle.append(user.id)
if len(raffle) == 0:
active_lottery.is_active = False
return True, "Lottery ended with no participants."
winner = choice(raffle)
active_lottery.winner_id = winner
winning_user = next(filter(lambda x: x.id == winner, participating_users))
@ -58,7 +62,6 @@ def end_lottery_session():
active_lottery.is_active = False
return True, f'{winning_user.username} won {active_lottery.prize} coins!'