コード例 #1
0
 def create_jobs(self, data: list) -> tuple:
     ids = []
     for mutation in graphql.get_create_mutations(data):
         response = json.loads(super().execute(mutation))
         if 'createJob' in response and 'id' in response['createJob']:
             ids.append(response['createJob']['id'])
     return tuple(ids)
コード例 #2
0
 def get_tasks(self, namespace: str) -> tuple:
     url = self.task_service_url + '?namespace=' + namespace
     headers = {'authorization': self.token}
     response = requests.get(url=url, headers=headers)
     if response.status_code is not 200:
         raise ValueError(response.text)
     response = json.loads(response.text)
     if len(response) is not 2:
         raise ValueError
     return response[0], response[1]
コード例 #3
0
 def get_jobs(self,
              where: dict = None,
              fields: tuple = ('id', ),
              limit: int = 0) -> list:
     if where is None:
         where = {}
     query = graphql.get_jobs_query(where=where, fields=fields, limit=limit)
     response = super().execute(query=query)
     response = json.loads(response)
     if 'jobs' in response:
         return response['jobs']
     return response
コード例 #4
0
 def reserve_jobs(self, worker: str, job_ids: tuple):
     mutation = graphql.get_reserve_jobs_mutation(worker=worker,
                                                  job_ids=job_ids)
     response = json.loads(super().execute(mutation))
     return response
コード例 #5
0
 def update_jobs(self, where: dict = None, data: dict = None) -> tuple:
     mutation = graphql.get_update_mutation(where=where, data=data)
     response = json.loads(super().execute(mutation))
     return response
コード例 #6
0
 def delete_jobs(self, where: dict = None) -> tuple:
     if where is None:
         where = {}
     mutation = graphql.get_delete_mutation(where=where)
     response = json.loads(super().execute(mutation))
     return response
コード例 #7
0
 def query(self, query: str, variables: str) -> list:
     return json.loads(super().execute(query=query, variables=variables))
コード例 #8
0
      slug
      primaryContact
      events {
        name
        numEntrants
      }
    }
  }
}
''', {
        "perPage": perPage,
        "coordinates": coordinates,
        "radius": radius
    })

resData = json.loads(result)
f = open("./public/tournaments.json", "w")

if 'errors' in resData:
    f.write('Error:')
    f.write(json.dumps(resData['errors']))
else:
    del resData['extensions']
    for tournie in resData["data"]["tournaments"]["nodes"]:
        try:
            imageURL = tournie["images"][0]["url"]
        except IndexError:
            imageURL = "https://www.ssbwiki.com/images/c/c2/SmashBrosSymbol.svg"

        del tournie["images"]
        tournie.update({"imageURL": imageURL})