def get_fight_info(fight, guild, unique_id):
    code = fight['log_code']
    fight_ID = fight['id']
    start_time = fight['start_time']
    end_time = fight['end_time']
    query = ('\n    {\n    reportData{\n        report(code: "%s"){\n        table(fightIDs: %s, startTime: %s, endTime: %s)\n        }\n    }\n    }\n    ' % (code, fight_ID, str(start_time), str(end_time)))
    r = requests.post(graphql_endpoint, json={'query': query}, headers=headers)
    table = r.json()['data']['reportData']['report']['table']['data']
    comp = table['composition']
    roles = table['playerDetails']
    player_list = []
    for role in roles:
        players = roles[role]
        for player in players:
            try:
                gear_ilvl = [piece['itemLevel'] for piece in player['combatantInfo']['gear']]
                ilvl = np.mean(gear_ilvl)
            except:
                try:
                    ilvl = player['minItemLevel']
                except:
                    ilvl = np.NaN
            try:
                covenant = player['combatantInfo']['covenantID']
            except:
                covenant = np.NaN
            try:
                spec = player['specs'][0]
            except:
                spec = np.NaN
            try:
                stats = player['combatantInfo']['stats']
                primaries = ['Agility', 'Intellect', 'Strength']
                for primary in primaries:
                    if (primary in stats.keys()):
                        break
                primary = stats[primary]['min']
                mastery = stats['Mastery']['min']
                crit = stats['Crit']['min']
                haste = stats['Haste']['min']
                vers = stats['Versatility']['min']
                stamina = stats['Stamina']['min']
            except:
                primary = np.NaN
                mastery = np.NaN
                crit = np.NaN
                haste = np.NaN
                vers = np.NaN
                stamina = np.NaN
            player_info = {'unique_id': unique_id, 'class': player['type'], 'spec': spec, 'role': role, 'ilvl': ilvl, 'covenant': covenant, 'primary': primary, 'mastery': mastery, 'crit': crit, 'haste': haste, 'vers': vers, 'stamina': stamina, 'boss_name': fight['name']}
            player_list.append(player_info)
    return player_list
def get_fight_info(fight, guild, unique_id):
    code = fight['log_code']
    fight_ID = fight['id']
    start_time = fight['start_time']
    end_time = fight['end_time']
    query = ('\n    {\n    reportData{\n        report(code: "%s"){\n        table(fightIDs: %s, startTime: %s, endTime: %s)\n        }\n    }\n    }\n    ' % (code, fight_ID, str(start_time), str(end_time)))
    r = requests.post(graphql_endpoint, json={'query': query}, headers=headers)
    table = r.json()['data']['reportData']['report']['table']['data']
    comp = table['composition']
    roles = table['playerDetails']
    player_list = []
    for role in roles:
        players = roles[role]
        for player in players:
            try:
                gear_ilvl = [piece['itemLevel'] for piece in player['combatantInfo']['gear']]
                ilvl = np.mean(gear_ilvl)
            except:
                try:
                    ilvl = player['minItemLevel']
                except:
                    ilvl = np.NaN
            try:
                covenant = player['combatantInfo']['covenantID']
            except:
                covenant = np.NaN
            try:
                spec = player['specs'][0]
            except:
                spec = np.NaN
            try:
                stats = player['combatantInfo']['stats']
                primaries = ['Agility', 'Intellect', 'Strength']
                for primary in primaries:
                    if (primary in stats.keys()):
                        break
                primary = stats[primary]['min']
                mastery = stats['Mastery']['min']
                crit = stats['Crit']['min']
                haste = stats['Haste']['min']
                vers = stats['Versatility']['min']
                stamina = stats['Stamina']['min']
            except:
                primary = np.NaN
                mastery = np.NaN
                crit = np.NaN
                haste = np.NaN
                vers = np.NaN
                stamina = np.NaN
            player_info = {'unique_id': unique_id, 'class': player['type'], 'spec': spec, 'role': role, 'ilvl': ilvl, 'covenant': covenant, 'primary': primary, 'mastery': mastery, 'crit': crit, 'haste': haste, 'vers': vers, 'stamina': stamina, 'boss_name': fight['name']}
            player_list.append(player_info)
    return player_list