-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:UnitapApp/unitap-backend into de…
…velop
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import csv | ||
from prizetap.models import LineaRaffleEntries, Raffle | ||
from prizetap.utils import LineaPrizetapContractClient | ||
|
||
|
||
def get_winners(raffle): | ||
raffle_client = LineaPrizetapContractClient(raffle) | ||
winner_addresses = raffle_client.get_raffle_winners() | ||
return winner_addresses | ||
|
||
|
||
def set_winners(raffle, winner_addresses): | ||
for entry in raffle.linea_entries: | ||
if entry.wallet_address in winner_addresses: | ||
entry.is_winner = True | ||
entry.save() | ||
|
||
|
||
def count_winners(raffle): | ||
winners = 0 | ||
for entry in raffle.linea_entries: | ||
if entry.is_winner: | ||
winners += 1 | ||
print(winners) | ||
|
||
|
||
linea_raffle = Raffle.objects.get(name="Linea Gas Pass") | ||
count_winners(linea_raffle) | ||
winners = get_winners(linea_raffle) | ||
print("a", winners) | ||
print("b", len(winners)) | ||
set_winners(linea_raffle, winners) | ||
count_winners("a", linea_raffle) |