Finish restructuring files
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 14s

This commit is contained in:
2024-02-24 17:41:12 +01:00
parent fc8a890511
commit 3704192730
40 changed files with 798 additions and 693 deletions

View File

@ -0,0 +1,33 @@
from datetime import datetime
from typing import List
from urllib.parse import quote
from sqlalchemy import DateTime, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from formula10 import db
class Race(db.Model):
"""
A single race at a certain date and GrandPrix in the calendar.
It stores the place to guess for this race.
"""
__tablename__ = "race"
@staticmethod
def from_csv(row: List[str]):
race: Race = Race()
race.name = str(row[0])
race.number = int(row[1])
race.date = datetime.strptime(row[2], "%Y-%m-%d")
race.pxx = int(row[3])
return race
@property
def name_sanitized(self) -> str:
return quote(self.name)
name: Mapped[str] = mapped_column(String(64), primary_key=True)
number: Mapped[int] = mapped_column(Integer)
date: Mapped[datetime] = mapped_column(DateTime)
pxx: Mapped[int] = mapped_column(Integer) # This is the place to guess