Skip to content

Commit

Permalink
v1.2, CHANGELOG.md for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremySkalla committed Mar 4, 2022
1 parent acd3679 commit 3b04a4b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# **v1.2**

- I figured I've been doing so many minor updates we'll call this a new version
- Added `tournament_show_by_owner(owner, page_num)`
- Added `startAt` to `tournament_show_event_by_game_size_dated`

# **v1.1 thru v1.1.6**

- Added game results (and then fixed a bug with them)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ print(tournaments_by_radius)
# Shows players at tournaments from a certain sponsor/prefix
players_by_sponsor = smash.tournament_show_players_by_sponsor('genesis-7', 'C9')
print(players_by_sponsor)

# Shows tournaments by owner
tournaments_by_owner = smash.tournament_show_by_owner(161429, 1)
print(tournaments_by_owner)
```

## **Event Usage**
Expand Down
31 changes: 26 additions & 5 deletions pysmashgg/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ def show_event_by_game_size_dated_filter(response, size, videogame_id):
cur_event['tournamentSlug'] = node['slug'].split('/')[-1]
cur_event['tournamentId'] = node['id']
cur_event['online'] = node['isOnline']
cur_event['startAt'] = node['startAt']
cur_event['endAt'] = node['endAt']
cur_event['eventName'] = event['name']
cur_event['eventId'] = event['id']
Expand Down Expand Up @@ -562,11 +563,6 @@ def show_by_radius_filter(response):
cur_tournament['city'] = node['city']
cur_tournament['startTimestamp'] = node['startAt']
cur_tournament['endTimestamp'] = node['endAt']
# IMPLEMENT THIS ONCE I ACTUALLY UNDERSTAND HOW STATE WORKS
# if node['state'] == 3:
# cur_tournament['completed'] = True
# else:
# cur_tournament['completed'] = False

tournaments.append(cur_tournament)

Expand Down Expand Up @@ -595,6 +591,31 @@ def show_players_by_sponsor_filter(response):

return players

def show_by_owner_filter(response):
if response['data']['tournaments'] is None:
return

if response['data']['tournaments']['nodes'] is None:
return

tournaments = []

for node in response['data']['tournaments']['nodes']:
cur_tournament = {}
cur_tournament['id'] = node['id']
cur_tournament['name'] = node['name']
cur_tournament['slug'] = node['slug'].split('/')[-1]
cur_tournament['entrants'] = node['numAttendees']
cur_tournament['country'] = node['countryCode']
cur_tournament['state'] = node['addrState']
cur_tournament['city'] = node['city']
cur_tournament['startTimestamp'] = node['startAt']
cur_tournament['endTimestamp'] = node['endAt']

tournaments.append(cur_tournament)

return tournaments

# BRACKETS.PY

# Filter for the show_entrants function
Expand Down
4 changes: 4 additions & 0 deletions pysmashgg/smashgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def tournament_show_by_radius(self, coordinates, radius, page_num):
# Players from a tournament with a certain sponsor
def tournament_show_players_by_sponsor(self, tournament_name, sponsor):
return tournaments.show_players_by_sponsor(tournament_name, sponsor, self.header, self.auto_retry)

# Tournaments by owner id
def tournament_show_by_owner(self, owner, page_num):
return tournaments.show_by_owner(owner, page_num, self.header, self.auto_retry)

# All entrants in a bracket (phaseGroup) at a tournament
def bracket_show_entrants(self, bracket_id, page_num):
Expand Down
25 changes: 24 additions & 1 deletion pysmashgg/t_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
id
slug
isOnline
startAt
endAt
events {
name
Expand Down Expand Up @@ -365,4 +366,26 @@
}
}
}
}"""
}"""

SHOW_BY_OWNER_QUERY = """query TournamentsByOwner($ownerId: ID!, $page: Int!) {
tournaments(query: {
perPage: 25,
page: $page,
filter: { ownerId: $ownerId }
}) {
nodes {
id
name
slug
numAttendees
countryCode
addrState
city
startAt
endAt
state
}
}
}
"""
6 changes: 6 additions & 0 deletions pysmashgg/tournaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,10 @@ def show_players_by_sponsor(tournament_name, sponsor, header, auto_retry):
variables = {"slug": tournament_name, "sponsor": sponsor}
response = run_query(SHOW_PLAYERS_BY_SPONSOR, variables, header, auto_retry)
data = filters.show_players_by_sponsor_filter(response)
return data

def show_by_owner(owner, page_num, header, auto_retry):
variables = {"ownerId": owner, "page": page_num}
response = run_query(SHOW_BY_OWNER_QUERY, variables, header, auto_retry)
data = filters.show_by_owner_filter(response)
return data
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pysmashgg",
version="1.1.6",
version="1.2",
author="Jeremy Skalla",
author_email="jthroughs@gmail.com",
description="Python Wrapper for smash.gg's GraphQL API",
Expand Down

0 comments on commit 3b04a4b

Please sign in to comment.