Allow specifying drivers as "inactive" and replace Logan Sargeant with Franco Colapinto
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 1m27s
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 1m27s
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Integer, String, ForeignKey
|
||||
from sqlalchemy import Integer, String, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from formula10.database.model.db_team import DbTeam
|
||||
@ -20,6 +20,7 @@ class DbDriver(db.Model):
|
||||
abbr: Mapped[str] = mapped_column(String(4), nullable=False, unique=True)
|
||||
team_id: Mapped[str] = mapped_column(ForeignKey("team.id"), nullable=False)
|
||||
country_code: Mapped[str] = mapped_column(String(2), nullable=False) # alpha-2 code
|
||||
active: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||
|
||||
# Relationships
|
||||
team: Mapped[DbTeam] = relationship("DbTeam", foreign_keys=[team_id])
|
@ -76,6 +76,19 @@ def find_multiple_strict(predicate: Callable[[_T], bool], iterable: Iterable[_T]
|
||||
return filtered
|
||||
|
||||
|
||||
def find_atleast_strict(predicate: Callable[[_T], bool], iterable: Iterable[_T], count: int = 0) -> List[_T]:
|
||||
"""
|
||||
Finds at least <count> elements in a sequence matching a predicate.
|
||||
Throws exception if fewer elements were found than specified.
|
||||
"""
|
||||
filtered = list(filter(predicate, iterable))
|
||||
|
||||
if len(filtered) < count:
|
||||
raise Exception(f"find_atleast found {len(filtered)} matching elements but expected at least {count}")
|
||||
|
||||
return filtered
|
||||
|
||||
|
||||
def find_single_strict(predicate: Callable[[_T], bool], iterable: Iterable[_T]) -> _T:
|
||||
"""
|
||||
Find a single element in a sequence matching a predicate.
|
||||
|
Reference in New Issue
Block a user