def get_winner(placement_data):
    if placement_data != None:
        placements = deserialize_placement_data(placement_data)
        for placement in placements:
            if placement.place == 1:
                return placement.user_id
    return None
def get_bowler_id_from_place(tournament_id, place):
    tournament = get_tournament(tournament_id)
    if tournament != None:
        placements = deserialize_placement_data(tournament.placement_data)
        for placement in placements:
            if placement.place == place:
                return placement.user_id
    return None
def get_average(tournament, user_id):
    average = 0
    if tournament != None:
        placements = deserialize_placement_data(tournament.placement_data)
        for placement in placements:
            if placement.user_id == user_id:
                average = placement.average_score
                break
    return average
def get_place(placement_data, user_id):
    place = 0
    if placement_data != None:
        placements = deserialize_placement_data(placement_data)
        for placement in placements:
            if placement.user_id == user_id:
                place = placement.place
                break
    return place
예제 #5
0
def fix_scraped_tournament_rosters():
    tournaments = Tournament.objects.filter(finished=True)
    for tournament in tournaments:
        roster = []
        placements = deserialize_placement_data(tournament.placement_data)
        for placement in placements:
            roster.append(str(placement.user_id))
        tournament.roster = serialize_roster_data(roster)
    Tournament.objects.bulk_update(tournaments)
def get_top_placements(placement_data, count):
    ids = []
    if placement_data != None:
        placements = deserialize_placement_data(placement_data)
        while count > 0:
            for placement in placements:
                if placement.place == count:
                    ids.append([placement.user_id, get_name_from_uuid(placement.user_id, True, True)])
                    break
            count -= 1
    return ids