Ejemplo n.º 1
0
def team_blue_banners(request):
    return render(request,
                  'leaderboard/alltime/team/blue_banners.html',
                  context={
                      'team_blue_banners':
                      TeamLeaderboard.most_blue_banners(DEFAULT_SHOW)
                  })
Ejemplo n.º 2
0
def team_win_rate(request):
    return render(request,
                  'leaderboard/alltime/team/winrate.html',
                  context={
                      'team_winrate':
                      TeamLeaderboard.highest_win_rate(DEFAULT_SHOW)
                  })
Ejemplo n.º 3
0
def team_match_wins(request):
    return render(request,
                  'leaderboard/alltime/team/match_wins.html',
                  context={
                      'team_matches':
                      TeamLeaderboard.most_match_wins(DEFAULT_SHOW)
                  })
Ejemplo n.º 4
0
def team_longest_active_winstreak(request):
    return render(
        request,
        'leaderboard/alltime/team/longest_active_winstreak.html',
        context={
            'teams':
            TeamLeaderboard.longest_active_event_winstreak(DEFAULT_SHOW)
        })
Ejemplo n.º 5
0
    def handle(self, *args, **options):
        global verbose
        log = options['log']
        year = options['year']
        verbose = options['verbose']
        if log:
            with open('elo.tsv', 'w', encoding='utf-8') as file:
                elo_leaders = TeamLeaderboard.highest_elo_scaled()
                row_fmt = "%s\t%s\t%s\t%s"
                file.writelines([
                                    (row_fmt % (
                                        rank, str(team).replace("\t", ""), team.elo_scaled, team.elo_sigma)).replace(
                                        '"',
                                        "''")
                                    for rank, team in enumerate(elo_leaders, start=1)
                                    ])
                # Replace double quotes so we can post it to Gist without Github freaking out
                # Replace tab characters because Team 422 has a tab in their name (WHY?!)
                # More teams have commas than tabs in their names so just uses .tsv file
        elif options['event'] == '':
            time_start = clock()
            if year == 0:
                for yr in SUPPORTED_YEARS[:-1]:
                    add_all_elo(yr)
                    soft_reset(yr)

                add_all_elo(SUPPORTED_YEARS[-1])
            else:
                add_all_elo(year)
            time_end = clock()
            print("-------------")
            print("Matches added:\t\t{0}".format(matches_added))
            print("Ran in {0} seconds.".format(round(time_end - time_start, 3)))
            print("-------------")
        else:
            # add_event_elo(Event.objects.get(key=options['event']))
            from cProfile import Profile
            profiler = Profile()
            profiler.runcall(add_event_elo, Event.objects.get(key=options['event']))
            profiler.print_stats(2)
Ejemplo n.º 6
0
def team_elo(request):
    return render(
        request,
        'leaderboard/alltime/team/elo_leaders.html',
        context={'team_elo': TeamLeaderboard.highest_elo_scaled(DEFAULT_SHOW)})
Ejemplo n.º 7
0
def team_award_wins(request):
    return render(
        request,
        'leaderboard/alltime/team/awards.html',
        context={'team_awards': TeamLeaderboard.most_award_wins(DEFAULT_SHOW)})
Ejemplo n.º 8
0
def test_leaderboard(num=10):
    print("Most 2-way alliance match wins:")
    start = clock()
    res = AllianceLeaderboard.most_match_wins_2(num)
    end = clock()
    pprint(res)
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Most 3-way alliance match wins:")
    start = clock()
    res = AllianceLeaderboard.most_match_wins_3(num)
    end = clock()
    pprint(res)
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Most 2-way alliance event wins:")
    start = clock()
    res = AllianceLeaderboard.most_event_wins_2(num)
    end = clock()
    pprint(res)
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Most 3-way alliance event wins:")
    start = clock()
    res = AllianceLeaderboard.most_event_wins_3(num)
    end = clock()
    pprint(res)
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Most team match wins:")
    start = clock()
    res = TeamLeaderboard.most_match_wins(num)
    end = clock()
    for r in res:
        pprint((r, r.stat))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Most team event wins:")
    start = clock()
    res = TeamLeaderboard.most_event_wins(num)
    end = clock()
    for r in res:
        pprint((r, r.stat))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest event average match scores:")
    start = clock()
    res = Leaderboard2016.highest_event_match_average_score(num * 2)
    end = clock()
    for r in res:
        pprint((r, r.avg_score))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest win rate teams:")
    start = clock()
    res = TeamLeaderboard.highest_win_rate(num * 5)
    end = clock()
    for r in res:
        pprint((r, r.stat))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Ranking Points records")
    start = clock()
    res = Leaderboard2016.highest_team_ranking_points(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.ranking_score))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest ranking points per game")
    start = clock()
    res = Leaderboard2016.highest_team_ranking_points_per_game(int(1.5 * num))
    end = clock()
    for r in res:
        pprint((r, r.avg_ranking))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Auton records")
    start = clock()
    res = Leaderboard2016.highest_team_auton_points(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.auton_points))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest auton points per game")
    start = clock()
    res = Leaderboard2016.highest_team_auton_points_per_game(int(1.5 * num))
    end = clock()
    for r in res:
        pprint((r, r.avg_auton))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Scale/Challenge records")
    start = clock()
    res = Leaderboard2016.highest_team_scale_challenge_points(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.scale_challenge_points))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest scale/challenge points per game")
    start = clock()
    res = Leaderboard2016.highest_team_scale_challenge_points_per_game(
        int(1.5 * num))
    end = clock()
    for r in res:
        pprint((r, r.avg_scale))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Goals records")
    start = clock()
    res = Leaderboard2016.highest_team_goals_points(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.goals_points))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest goal points per game")
    start = clock()
    res = Leaderboard2016.highest_team_goals_points_per_game(int(1.5 * num))
    end = clock()
    for r in res:
        pprint((r, r.avg_goals))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Defense records")
    start = clock()
    res = Leaderboard2016.highest_team_defense_points(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.defense_points))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("Highest defense points per game")
    start = clock()
    res = Leaderboard2016.highest_team_defense_points_per_game(int(1.5 * num))
    end = clock()
    for r in res:
        pprint((r, r.avg_defense))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("OPR records")
    start = clock()
    res = Leaderboard2016.highest_team_opr(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.tba_opr))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("DPR records")
    start = clock()
    res = Leaderboard2016.highest_team_dpr(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.tba_dpr))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("CCWMS records")
    start = clock()
    res = Leaderboard2016.highest_team_ccwms(1.5 * num)
    end = clock()
    for r in res:
        pprint((r, r.tba_ccwms))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")

    print("High score matches")
    start = clock()
    res = Leaderboard2016.highest_score_matches(num * 1.5)
    end = clock()
    for r in res:
        pprint((r, r.match_set.first(), r.hs))
    print("Operation took {0} seconds".format((end - start).__round__(3)))
    print("------------------------------------------")