Files
flask-formula10/formula10/database/model/db_race_result.py
Christoph Urlacher 8b2920f886
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 20s
Add dummy values to race result
These columns are not marked nullable, so ignoring them prevents entering of race results
2024-03-09 19:48:07 +01:00

30 lines
1.4 KiB
Python

from sqlalchemy import ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from formula10.database.model.db_driver import DbDriver
from formula10.database.model.db_race import DbRace
from formula10 import db
class DbRaceResult(db.Model):
"""
The result of a past race.
It stores the corresponding race and dictionaries of place-/dnf-order and a list of drivers that are excluded from the standings for this race.
"""
__tablename__ = "raceresult"
def __init__(self, *, race_id: int):
self.race_id = race_id # Primary key
race_id: Mapped[int] = mapped_column(ForeignKey("race.id"), primary_key=True)
pxx_driver_ids_json: Mapped[str] = mapped_column(String(1024), nullable=False)
first_dnf_driver_ids_json: Mapped[str] = mapped_column(String(1024), nullable=False)
dnf_driver_ids_json: Mapped[str] = mapped_column(String(1024), nullable=False)
excluded_driver_ids_json: Mapped[str] = mapped_column(String(1024), nullable=False)
fastest_lap_id: Mapped[int] = mapped_column(ForeignKey("driver.id"), nullable=False)
sprint_dnf_driver_ids_json: Mapped[str] = mapped_column(String(1024), nullable=False)
sprint_points_json: Mapped[str] = mapped_column(String(1024), nullable=False)
# Relationships
race: Mapped[DbRace] = relationship("DbRace", foreign_keys=[race_id])
fastest_lap_driver: Mapped[DbDriver] = relationship("DbDriver", foreign_keys=[fastest_lap_id])