forked from rDrama/rDrama
cron.py bugs: missing import; lottery edge case
parent
0fe1e57ecd
commit
be1023f734
|
@ -1,6 +1,7 @@
|
||||||
from files.cli import g, app, db_session
|
from files.cli import g, app, db_session
|
||||||
import click
|
import click
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
|
from files.classes import *
|
||||||
|
|
||||||
import files.helpers.lottery as lottery
|
import files.helpers.lottery as lottery
|
||||||
import files.helpers.offsitementions as offsitementions
|
import files.helpers.offsitementions as offsitementions
|
||||||
|
|
|
@ -38,6 +38,10 @@ def end_lottery_session():
|
||||||
for _ in range(user.currently_held_lottery_tickets):
|
for _ in range(user.currently_held_lottery_tickets):
|
||||||
raffle.append(user.id)
|
raffle.append(user.id)
|
||||||
|
|
||||||
|
if len(raffle) == 0:
|
||||||
|
active_lottery.is_active = False
|
||||||
|
return True, "Lottery ended with no participants."
|
||||||
|
|
||||||
winner = choice(raffle)
|
winner = choice(raffle)
|
||||||
active_lottery.winner_id = winner
|
active_lottery.winner_id = winner
|
||||||
winning_user = next(filter(lambda x: x.id == winner, participating_users))
|
winning_user = next(filter(lambda x: x.id == winner, participating_users))
|
||||||
|
@ -58,7 +62,6 @@ def end_lottery_session():
|
||||||
|
|
||||||
active_lottery.is_active = False
|
active_lottery.is_active = False
|
||||||
|
|
||||||
|
|
||||||
return True, f'{winning_user.username} won {active_lottery.prize} coins!'
|
return True, f'{winning_user.username} won {active_lottery.prize} coins!'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue