Skip to content

Commit

Permalink
FIX: Ergast results position filter missing and/or not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lombardoc4 authored Dec 28, 2023
1 parent dc16a93 commit 1b6a823
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions fastf1/ergast/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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}

Expand Down Expand Up @@ -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,
Expand All @@ -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``
Expand All @@ -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',
Expand Down

0 comments on commit 1b6a823

Please sign in to comment.