Skip to content

Commit

Permalink
formatting dumps for fastest lap
Browse files Browse the repository at this point in the history
    * object_type should be lap not fastest_lap
    * objects should be a list of dicts, not a dict
    * lap_number should be number
  • Loading branch information
harningle committed Sep 26, 2024
1 parent bcaf915 commit c8edcd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions models/lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class QualiLap(BaseModel):


class FastestLap(BaseModel):
lap_number: PositiveInt
number: PositiveInt
fastest_lap_rank: PositiveInt

model_config = ConfigDict(extra='forbid')
Expand All @@ -39,8 +39,8 @@ class LapData(BaseModel):


class FastestLapData(BaseModel):
object_type: str = 'fastest_lap'
object_type: str = 'lap'
foreign_keys: SessionEntry
objects: FastestLap
objects: list[FastestLap]

model_config = ConfigDict(extra='forbid')
6 changes: 3 additions & 3 deletions parse_race_fastest_laps.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def to_json(df: pd.DataFrame) -> list[dict]:
session=session_type,
car_number=x['driver_no']
),
objects=FastestLap(
lap_number=x['lap'],
objects=[FastestLap(
number=x['lap'],
fastest_lap_rank=x['rank']
)
)]
).model_dump(),
axis=1
)
Expand Down

0 comments on commit c8edcd2

Please sign in to comment.