-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
55 lines (39 loc) · 1.42 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from typing import Optional
from datetime import date, time
from sqlmodel import SQLModel, Field, Relationship
class Rider(SQLModel, table=True):
rider_id: Optional[int] = Field(default=None, primary_key=True)
name: str
isJunior: bool
isFemale: bool
results: list['EventResult'] = Relationship(back_populates='rider')
class Event(SQLModel, table=True):
event_id: int = Field(default=None, primary_key=True)
date: date
results: list['EventResult'] = Relationship(back_populates='event')
class EventResult(SQLModel, table=True):
results_id: Optional[int] = Field(default=None, primary_key=True)
event_id: Optional[int] = Field(default=None, foreign_key='event.event_id')
rider_id: Optional[int] = Field(default=None, foreign_key='rider.rider_id')
category: str
total_time: time
fastest_lap_time: Optional[time] = Field(default=None)
fastest_lap: Optional[int] = Field(default=None)
laps_completed: int
event: Optional[Event] = Relationship(back_populates='results')
rider: Optional[Rider] = Relationship(back_populates='results')
class FastestLap(SQLModel):
rider_id: int
name: str
fastest_lap_time: time | None
fastest_lap: int | None
event_id: int
class FastestEvent(SQLModel):
rider_id: int
name: str
total_time: time | None
event_id: int
class Ranking(SQLModel):
rider_id: int | None
name: str
seconds: float