tracinginsights commited on
Commit
64b17e8
1 Parent(s): d047e59

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -8
main.py CHANGED
@@ -13,7 +13,7 @@ from pydantic import BaseModel
13
  import functools
14
  import math
15
  import numpy as np
16
-
17
 
18
 
19
  import available_data
@@ -257,13 +257,16 @@ async def session_drivers(year: int, event: str | int, session: str) -> any:
257
 
258
  # get drivers available for a given year, event and session
259
  f1session = fastf1.get_session(year, event, session)
260
- api_path = f1session.api_path
261
- drivers_raw = fastf1.api.driver_info(api_path)
262
- drivers = [{
263
- "color": available_data.team_colors(year)[driver[1]['TeamName']],
264
- "label": driver[1]['Tla'],
265
- "value": driver[1]['Tla']
266
- } for driver in drivers_raw.items()]
 
 
 
267
 
268
 
269
  return {"drivers": drivers}
 
13
  import functools
14
  import math
15
  import numpy as np
16
+ import concurrent.futures
17
 
18
 
19
  import available_data
 
257
 
258
  # get drivers available for a given year, event and session
259
  f1session = fastf1.get_session(year, event, session)
260
+ f1session.load(telemetry=False, weather=False, messages=False)
261
+ laps = f1session.laps
262
+
263
+ team_colors = available_data.team_colors(year)
264
+
265
+ drivers = laps.Driver.unique()
266
+ # for each driver in drivers, get the Team column from laps and get the color from team_colors dict
267
+ drivers = [{"color": team_colors[laps[laps.Driver ==
268
+ driver].Team.iloc[0]], "label": driver, "value": driver} for driver in drivers]
269
+
270
 
271
 
272
  return {"drivers": drivers}