From 1b6a8238c48c52579e09fe39033c126777792546 Mon Sep 17 00:00:00 2001 From: Cris Lom <36197748+Lombardoc4@users.noreply.github.com> Date: Thu, 28 Dec 2023 14:56:34 -0500 Subject: [PATCH] FIX: Ergast results position filter missing and/or not working correctly --- fastf1/ergast/interface.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fastf1/ergast/interface.py b/fastf1/ergast/interface.py index 674a68e9d..7790abdcc 100644 --- a/fastf1/ergast/interface.py +++ b/fastf1/ergast/interface.py @@ -444,8 +444,6 @@ def _build_url( selectors.append(f"/{round}") if grid_position is not None: selectors.append(f"/grid/{grid_position}") - if results_position is not None: - selectors.append(f"/results/{results_position}") if fastest_rank is not None: selectors.append(f"/fastest/{fastest_rank}") @@ -482,6 +480,12 @@ def _build_url( elif endpoint == 'constructorStandings': endpoint = f"constructorStandings/{standings_position}" + if results_position is not None: + if endpoint in ('results', 'qualifying', 'sprint'): + endpoint = f"{endpoint}/{results_position}" + else: + selectors.append(f"/results/{results_position}") + if lap_number is not None: if endpoint == 'laps': endpoint = f"laps/{lap_number}" @@ -1019,6 +1023,7 @@ def get_race_results( constructor: Optional[str] = None, driver: Optional[str] = None, grid_position: Optional[int] = None, + results_position: Optional[int] = None, fastest_rank: Optional[int] = None, status: Optional[str] = None, result_type: Optional[Literal['pandas', 'raw']] = None, @@ -1042,6 +1047,8 @@ def get_race_results( (default: all) driver: select a driver by its driver id (default: all) grid_position: select a grid position by its number (default: all) + results_position: select a finishing result by its position + (default: all) fastest_rank: select fastest by rank number (default: all) status: select by finishing status (default: all) result_type: Overwrites the default result type @@ -1062,6 +1069,7 @@ def get_race_results( 'constructor': constructor, 'driver': driver, 'grid_position': grid_position, + 'results_position': results_position, 'fastest_rank': fastest_rank, 'status': status} @@ -1151,6 +1159,7 @@ def get_sprint_results( constructor: Optional[str] = None, driver: Optional[str] = None, grid_position: Optional[int] = None, + results_position: Optional[int] = None, status: Optional[str] = None, result_type: Optional[Literal['pandas', 'raw']] = None, auto_cast: Optional[bool] = None, @@ -1173,6 +1182,8 @@ def get_sprint_results( (default: all) driver: select a driver by its driver id (default: all) grid_position: select a grid position by its number (default: all) + results_position: select a finishing result by its position + (default: all) status: select by finishing status (default: all) result_type: Overwrites the default result type auto_cast: Overwrites the default value for ``auto_cast`` @@ -1192,6 +1203,7 @@ def get_sprint_results( 'constructor': constructor, 'driver': driver, 'grid_position': grid_position, + 'results_position': results_position, 'status': status} return self._build_default_result(endpoint='sprint',