Bug: Fix statistics issues caused by driver substitutions
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 16s

This commit is contained in:
2024-12-08 19:52:02 +01:00
parent 0dc4b22c72
commit 15305b2f3e

View File

@ -90,6 +90,33 @@ WDC_SUBSTITUTE_POINTS: List[Tuple[int, int, int]] = [
(8, 17, 1), # Bearman raced for Magnussen in Azerbaijan
]
WDC_STANDING_2024: Dict[str, int] = {
"Max Verstappen": 1,
"Lando Norris": 2,
"Charles Leclerc": 3,
"Oscar Piastri": 4,
"Carlos Sainz": 5,
"George Russell": 6,
"Lewis Hamilton": 7,
"Sergio Perez": 8,
"Fernando Alonso": 9,
"Pierre Gasly": 10,
"Nico Hulkenberg": 11,
"Yuki Tsunoda": 12,
"Lance Stroll": 13,
"Esteban Ocon": 14,
"Kevin Magnussen": 15,
"Alexander Albon": 16,
"Daniel Ricciardo": 17,
"Oliver Bearman": 18,
"Franco Colapinto": 19,
"Zhou Guanyu": 20,
"Liam Lawson": 21,
"Valtteri Bottas": 22,
"Logan Sargeant": 23,
"Jack Doohan": 24
}
def standing_points(race_guess: RaceGuess, race_result: RaceResult) -> int:
guessed_driver_position: int | None = race_result.driver_standing_position(
driver=race_guess.pxx_guess
@ -360,6 +387,7 @@ class PointsModel(Model):
def wdc_standing_by_position(self) -> Dict[int, List[str]]:
standing: Dict[int, List[str]] = dict()
if WDC_STANDING_2024 is None:
for position in range(
1, len(self.all_drivers(include_none=False, include_inactive=True)) + 1
):
@ -378,6 +406,13 @@ class PointsModel(Model):
standing[position].append(driver.name)
last_points = points
if WDC_STANDING_2024 is not None:
for position in range(1, len(WDC_STANDING_2024) + 1):
standing[position] = list()
for driver, position in WDC_STANDING_2024.items():
standing[position] += [driver]
return standing
@cache.cached(
@ -386,6 +421,7 @@ class PointsModel(Model):
def wdc_standing_by_driver(self) -> Dict[str, int]:
standing: Dict[str, int] = dict()
if WDC_STANDING_2024 is None:
position: int = 1
last_points: int = 0
@ -406,6 +442,9 @@ class PointsModel(Model):
return standing
if WDC_STANDING_2024 is not None:
return WDC_STANDING_2024
def wdc_diff_2023_by(self, driver_name: str) -> int:
if not driver_name in WDC_STANDING_2023:
return 0