def player_info_json(request): """ Provides detailed information on a specific player. JSON. """ # All player_info fields are converted into JSON-formattable dictionaries player_info = player_info_data(request) player = player_info['player'].to_dict() games_played = {} for game in player_info['games_played']: games_played[game.game_type_cd] = to_json(game) overall_stats = {} for gt,stats in player_info['overall_stats'].items(): overall_stats[gt] = to_json(stats) elos = {} for gt,elo in player_info['elos'].items(): elos[gt] = to_json(elo.to_dict()) ranks = {} for gt,rank in player_info['ranks'].items(): ranks[gt] = to_json(rank) fav_maps = {} for gt,mapinfo in player_info['fav_maps'].items(): fav_maps[gt] = to_json(mapinfo) recent_games = [g.to_dict() for g in player_info['recent_games']] return [{ 'player': player, 'games_played': games_played, 'overall_stats': overall_stats, 'fav_maps': fav_maps, 'elos': elos, 'ranks': ranks, 'recent_games': recent_games, }]
def player_elo_info_json(request): """ Provides elo information on a specific player. JSON. """ elo_info = player_elo_info_data(request) player = player_info["player"].to_dict() elos = {} for gt, elo in elo_info["elos"].items(): elos[gt] = to_json(elo.to_dict()) return [{"version": 1, "player": player, "elos": elos}]
def player_elo_info_json(request): """ Provides elo information on a specific player. JSON. """ elo_info = player_elo_info_data(request) player = player_info['player'].to_dict() elos = {} for gt, elo in elo_info['elos'].items(): elos[gt] = to_json(elo.to_dict()) return [{ 'version': 1, 'player': player, 'elos': elos, }]
def player_info_json(request): """ Provides detailed information on a specific player. JSON. """ # All player_info fields are converted into JSON-formattable dictionaries player_info = player_info_data(request) player = player_info["player"].to_dict() games_played = {} for game in player_info["games_played"]: games_played[game.game_type_cd] = to_json(game) overall_stats = {} for gt, stats in player_info["overall_stats"].items(): overall_stats[gt] = to_json(stats) elos = {} for gt, elo in player_info["elos"].items(): elos[gt] = to_json(elo.to_dict()) ranks = {} for gt, rank in player_info["ranks"].items(): ranks[gt] = to_json(rank) fav_maps = {} for gt, mapinfo in player_info["fav_maps"].items(): fav_maps[gt] = to_json(mapinfo) recent_games = [] for game in player_info["recent_games"]: recent_games.append(to_json(game)) return [ { "player": player, "games_played": games_played, "overall_stats": overall_stats, "fav_maps": fav_maps, "elos": elos, "ranks": ranks, "recent_games": recent_games, } ]