Exemple #1
0
def index():
    print('index')
    mscores = get_mscores()
    stats = s_overall.OverallWinnerStat()
    stats.parse(mscores)
    print('rendering')
    return render_template('base.html', title=u'GAME STATS', stats=stats)
Exemple #2
0
def get_players():
    """
    : return: Get all player stats
    """
    stats = s_overall.OverallWinnerStat()
    stats.parse(get_mscores())
    return jsonify([player_stat.to_json()
                    for player_stat in stats.player_stats.values()])
Exemple #3
0
def get_player(player_id):
    """
    : return: the player with given ID
    """
    stats = s_overall.OverallWinnerStat()
    stats.parse(get_mscores())
    if player_id in stats.player_stats:
        return jsonify(stats.player_stats[player_id].to_json())
    return jsonify('Failed to find player with id %s' % player_id), 404
Exemple #4
0
def get_game(game_id):
    """
    : return: the game with given ID
    """
    stats = s_overall.OverallWinnerStat()
    stats.parse(get_mscores())
    if game_id in stats.game_stats:
        return jsonify(stats.game_stats[game_id].to_json())
    return jsonify('Failed to find game %s' % game_id), 404
Exemple #5
0
def get_play_elos(play_id):
    """
    : return: the elos of the play with given ID
    """
    stats = s_overall.OverallWinnerStat()
    stats.parse(get_mscores())
    elos_per_player = stats.elo_stats.get_elos_per_player(play_id)
    if elos_per_player:
        json_object = []
        for player_login, elos in elos_per_player.iteritems():
            json_object.append({
                "login": player_login,
                "elo_before": elos[0],
                "elo_after": elos[1],
                "elos": elos[1] - elos[0],
            })
        return jsonify(json_object)
    return jsonify('Failed to find elos of play with id %s' % play_id), 404
Exemple #6
0
def get_games():
    """Return the list of games"""
    stats = s_overall.OverallWinnerStat()
    stats.parse(get_mscores())
    return jsonify(sorted(list(stats.game_stats)))