From d918c26a9f1cf2f47385314fa96015b8afa79b5a Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Fri, 6 Aug 2021 16:13:56 -0500 Subject: [PATCH] Refactor, extract pulls and get example pull --- main.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 9a695b1..f2c7f90 100755 --- a/main.py +++ b/main.py @@ -4,6 +4,14 @@ from gql.transport.aiohttp import AIOHTTPTransport import requests from secrets import * +encounter_aliases = [ + 'cloudRanks', + 'dogRanks', + 'thanRanks', + 'boobaRanks', + 'gaiaRanks', +] + res = requests.post( "https://www.fflogs.com/oauth/token", data={"grant_type": "client_credentials"}, @@ -44,8 +52,28 @@ params = { "serverRegion": "na", } result = client.execute(query, variable_values=params) -print(result['characterData']['character']['cloudRanks']['ranks'][0]['report']) -print(result['characterData']['character']['dogRanks']['ranks'][0]['report']) -print(result['characterData']['character']['thanRanks']['ranks'][0]['report']) -print(result['characterData']['character']['boobaRanks']['ranks'][0]['report']) -print(result['characterData']['character']['gaiaRanks']['ranks'][0]['report']) +encounter_ranks = [result['characterData']['character'][encounter_alias] for encounter_alias in encounter_aliases] +ranks = [rank for encounter in encounter_ranks for rank in encounter['ranks']] +pulls = [(rank['report']['code'], rank['report']['fightID']) for rank in ranks] +query = gql( + ''' + query ($code: String!, $fightIds: [Int]!) { + reportData { + report ( + code: $code + ) + { + code + fights ( + fightIDs: $fightIds + ) + { + hasEcho + kill + } + } + } + } + ''' + ) +result = client.execute(query, variable_values={"code": pulls[0][0], "fightIds": pulls[0][1]}) -- 2.20.1