From db2f7ee0eed6612f43165d83e09e0b37744a3813 Mon Sep 17 00:00:00 2001 From: Corey Schaf Date: Mon, 11 Nov 2024 10:06:18 -0500 Subject: [PATCH] BugFix: skater_stats_summary_simple, goalie_stats_summary_simple: Fixes double encoding bug that breaks in notebooks (#80) --- nhlpy/api/stats.py | 4 ++-- pyproject.toml | 2 +- tests/test_stats.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nhlpy/api/stats.py b/nhlpy/api/stats.py index 855ff37..7d5d32f 100644 --- a/nhlpy/api/stats.py +++ b/nhlpy/api/stats.py @@ -153,7 +153,7 @@ def skater_stats_summary_simple( {"property": "gamesPlayed", "direction": "ASC"}, {"property": "playerId", "direction": "ASC"}, ] - q_params["sort"] = urllib.parse.quote(json.dumps(sort_expr)) + q_params["sort"] = json.dumps(sort_expr) if not default_cayenne_exp: default_cayenne_exp = f"gameTypeId={game_type_id} and seasonId<={end_season} and seasonId>={start_season}" @@ -263,7 +263,7 @@ def goalie_stats_summary_simple( if not sort_expr: sort_expr = _goalie_stats_sorts(report=stats_type) - q_params["sort"] = urllib.parse.quote(json.dumps(sort_expr)) + q_params["sort"] = json.dumps(sort_expr) if not default_cayenne_exp: default_cayenne_exp = f"gameTypeId={game_type_id} and seasonId<={end_season} and seasonId>={start_season}" diff --git a/pyproject.toml b/pyproject.toml index aa67fb8..07833bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "nhl-api-py" -version = "2.12.2" +version = "2.12.3" description = "NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats." authors = ["Corey Schaf "] readme = "README.md" diff --git a/tests/test_stats.py b/tests/test_stats.py index 59ae6db..220a731 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -80,9 +80,9 @@ def test_skater_stats_summary(h_m, nhl_client): "limit": 70, "start": 0, "factCayenneExp": "gamesPlayed>=1", - "sort": "%5B%7B%22property%22%3A%20%22points%22%2C%20%22direction%22%3A%20%22DESC%22%7D%2C%20%7B%22" - "property%22%3A%20%22gamesPlayed%22%2C%20%22direction%22%3A%20%22ASC%22%7D%2C%20%7B%22property%22" - "%3A%20%22playerId%22%2C%20%22direction%22%3A%20%22ASC%22%7D%5D", + "sort": '[{"property": "points", "direction": "DESC"}, {"property": ' + '"gamesPlayed", "direction": "ASC"}, {"property": "playerId", ' + '"direction": "ASC"}]', "cayenneExp": "gameTypeId=2 and seasonId<=20232024 and seasonId>=20232024", } @@ -98,9 +98,9 @@ def test_skater_stats_summary_franchise(h_m, nhl_client): "limit": 70, "start": 0, "factCayenneExp": "gamesPlayed>=1", - "sort": "%5B%7B%22property%22%3A%20%22points%22%2C%20%22direction%22%3A%20%22DESC%22%7D%2C%20%7B%22" - "property%22%3A%20%22gamesPlayed%22%2C%20%22direction%22%3A%20%22ASC%22%7D%2C%20%7B%22property%22" - "%3A%20%22playerId%22%2C%20%22direction%22%3A%20%22ASC%22%7D%5D", + "sort": '[{"property": "points", "direction": "DESC"}, {"property": ' + '"gamesPlayed", "direction": "ASC"}, {"property": "playerId", ' + '"direction": "ASC"}]', "cayenneExp": "franchiseId=19 and gameTypeId=2 and seasonId<=20232024 and seasonId>=20232024", }