Replace memoize with cached for teams_sorted_by_points
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 2m21s
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 2m21s
This commit is contained in:
@ -38,6 +38,7 @@ def cache_invalidate_race_result_updated() -> None:
|
|||||||
"points_most_gained_names",
|
"points_most_gained_names",
|
||||||
"points_most_lost_names",
|
"points_most_lost_names",
|
||||||
"points_team_points_per_step_cumulative",
|
"points_team_points_per_step_cumulative",
|
||||||
|
"points_teams_sorted_by_points",
|
||||||
"points_wcc_standing_by_position",
|
"points_wcc_standing_by_position",
|
||||||
"points_wcc_standing_by_team",
|
"points_wcc_standing_by_team",
|
||||||
"points_user_standing",
|
"points_user_standing",
|
||||||
@ -50,7 +51,6 @@ def cache_invalidate_race_result_updated() -> None:
|
|||||||
"total_driver_points_by",
|
"total_driver_points_by",
|
||||||
"drivers_sorted_by_points",
|
"drivers_sorted_by_points",
|
||||||
"total_team_points_by",
|
"total_team_points_by",
|
||||||
"teams_sorted_by_points",
|
|
||||||
"points_by",
|
"points_by",
|
||||||
"is_team_winner",
|
"is_team_winner",
|
||||||
"has_podium",
|
"has_podium",
|
||||||
|
@ -384,7 +384,7 @@ class PointsModel(Model):
|
|||||||
teammates: List[Driver] = self.drivers_by(team_name=team_name, include_inactive=True)
|
teammates: List[Driver] = self.drivers_by(team_name=team_name, include_inactive=True)
|
||||||
return sum(sum(self.driver_points_by(driver_name=teammate.name, include_inactive=True)) for teammate in teammates)
|
return sum(sum(self.driver_points_by(driver_name=teammate.name, include_inactive=True)) for teammate in teammates)
|
||||||
|
|
||||||
@cache.memoize(timeout=None, args_to_ignore=["self"]) # Cleanup when adding/updating race results
|
@cache.cached(timeout=None, key_prefix="points_teams_sorted_by_points") # Cleanup when adding/updating race results
|
||||||
def teams_sorted_by_points(self) -> List[Team]:
|
def teams_sorted_by_points(self) -> List[Team]:
|
||||||
comparator: Callable[[Team], int] = lambda team: self.total_team_points_by(team.name)
|
comparator: Callable[[Team], int] = lambda team: self.total_team_points_by(team.name)
|
||||||
return sorted(self.all_teams(include_none=False), key=comparator, reverse=True)
|
return sorted(self.all_teams(include_none=False), key=comparator, reverse=True)
|
||||||
|
Reference in New Issue
Block a user