Skip to content

Commit

Permalink
avoid crash due lack of time
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucocustodio committed Jul 2, 2023
1 parent 74d82cb commit cc89363
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
def get_match_data(row):
print(f"getting match data for {row['match_link']}")

def convert_to_int(value):
return int(value) if isinstance(value, (int, float)) else 99999

try:
match_data = get_te_match_json(match_url=row['match_link'])
row['player1_ranking'] = int(match_data['player1']['ranking_pos'].rstrip('.'))
row['player2_ranking'] = int(match_data['player2']['ranking_pos'].rstrip('.'))
row['player1_ranking'] = convert_to_int(match_data['player1']['ranking_pos'].rstrip('.'))
row['player2_ranking'] = convert_to_int(match_data['player2']['ranking_pos'].rstrip('.'))
row['surface'] = match_data['surface']
row['event_name'] = match_data['event_name']
row['tournament'] = match_data['tournament']
Expand All @@ -46,6 +49,7 @@ def get_match_data(row):
# head function is used just in case I want to limit when developing locally
# get games of the day when both players have ranking position <= relevant_rank
match_data = games\
.query('time != "--:--"')\
.head(1000)\
.parallel_apply(get_match_data, axis=1)\
.query('status != "complete"')\
Expand Down Expand Up @@ -106,7 +110,8 @@ def hashify(name):


if len(full_games) == 0:
sys.exit("no relevant games found for this day!!")
print(f"{match_type}: no relevant games found for this day!!\n\n".upper())
continue

# to debug with breakpoint(), use apply instead of parallel_apply
final = full_games.dropna().parallel_apply(get_player_data, axis=1)
Expand Down

0 comments on commit cc89363

Please sign in to comment.