Sort leaderboard table by total points
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 14s
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 14s
This commit is contained in:
@ -41,6 +41,7 @@ import formula10.controller.error_controller
|
||||
# General
|
||||
# - Decouple names from IDs + Fix Valtteri/Russel spelling errors
|
||||
# - Unit testing (as much as possible, but especially points calculation)
|
||||
# - Add links to the official F1 stats page (for quali/result)
|
||||
|
||||
# Possible but probably not
|
||||
# - Show cards of previous race results, like with season guesses?
|
||||
|
@ -1,10 +1,11 @@
|
||||
from typing import Dict, List, overload
|
||||
from typing import Callable, Dict, List, overload
|
||||
import numpy as np
|
||||
|
||||
from formula10.domain.domain_model import Model
|
||||
from formula10.domain.model.driver import NONE_DRIVER
|
||||
from formula10.domain.model.race_guess import RaceGuess
|
||||
from formula10.domain.model.race_result import RaceResult
|
||||
from formula10.domain.model.user import User
|
||||
|
||||
RACE_GUESS_OFFSET_POINTS: Dict[int, int] = {
|
||||
3: 1,
|
||||
@ -156,6 +157,10 @@ class PointsModel(Model):
|
||||
"""
|
||||
return sum(self.points_by(user_name=user_name))
|
||||
|
||||
def users_sorted_by_points(self) -> List[User]:
|
||||
comparator: Callable[[User], int] = lambda user: self.total_points_by(user.name)
|
||||
return sorted(self.all_users(), key=comparator, reverse=True)
|
||||
|
||||
def picks_count(self, user_name: str) -> int:
|
||||
# Treat standing + dnf picks separately
|
||||
return len(self.race_guesses_by(user_name=user_name)) * 2
|
||||
|
@ -23,7 +23,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for user in model.all_users() %}
|
||||
{% for user in points.users_sorted_by_points() %}
|
||||
<tr>
|
||||
<td class="text-center text-nowrap">{{ user.name }}</td>
|
||||
<td class="text-center text-nowrap">{{ points.total_points_by(user.name) }}</td>
|
||||
|
Reference in New Issue
Block a user