tracinginsights commited on
Commit
8411795
·
1 Parent(s): e731dd3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -11
main.py CHANGED
@@ -262,17 +262,13 @@ async def session_drivers(year: int, event: str | int, session: str) -> any:
262
 
263
  # get drivers available for a given year, event and session
264
  f1session = fastf1.get_session(year, event, session)
265
- f1session.load(telemetry=False, weather=False, messages=False)
266
- laps = f1session.laps
267
-
268
- team_colors = available_data.team_colors(year)
269
-
270
- drivers = laps.Driver.unique()
271
- # for each driver in drivers, get the Team column from laps and get the color from team_colors dict
272
- drivers = [{"color": team_colors[laps[laps.Driver ==
273
- driver].Team.iloc[0]], "label": driver, "value": driver} for driver in drivers]
274
-
275
-
276
 
277
  return {"drivers": drivers}
278
 
 
262
 
263
  # get drivers available for a given year, event and session
264
  f1session = fastf1.get_session(year, event, session)
265
+ api_path = f1session.api_path
266
+ drivers_raw = fastf1.api.driver_info(api_path)
267
+ drivers = [{
268
+ "color": available_data.team_colors(year)[driver[1]['TeamName']],
269
+ "label": driver[1]['Tla'],
270
+ "value": driver[1]['Tla']
271
+ } for driver in drivers_raw.items()]
 
 
 
 
272
 
273
  return {"drivers": drivers}
274