Files
flask-formula10/formula10/database/model/db_race_result.py
Christoph Urlacher d3097038a5
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 15s
Large database migration
2024-03-03 15:38:35 +01:00

24 lines
1.0 KiB
Python

from sqlalchemy import ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
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)
# Relationships
race: Mapped[DbRace] = relationship("DbRace", foreign_keys=[race_id])