diff --git a/polylan_submitter/clock/api.py b/polylan_submitter/clock/api.py index 59f72b8..c8467bf 100644 --- a/polylan_submitter/clock/api.py +++ b/polylan_submitter/clock/api.py @@ -54,8 +54,8 @@ def current_state(request: HttpRequest, event_path: str): def my_stats(request: HttpRequest, event_path: str): ranked = list( ranked_players(request.event) - .values("id", "points", "rank") - .order_by("-points", "id") + .values("id", "clock_points", "rank") + .order_by("-clock_points", "id") ) total_players = len(ranked) my_index = next( @@ -71,9 +71,9 @@ def my_stats(request: HttpRequest, event_path: str): ) return { - "points": mine["points"] if mine else 0.0, + "points": mine["clock_points"] if mine else 0.0, "rank": mine["rank"] if mine else total_players, "total_players": total_players, - "points_above": above["points"] if above else None, - "points_below": below["points"] if below else None, + "points_above": above["clock_points"] if above else None, + "points_below": below["clock_points"] if below else None, } diff --git a/polylan_submitter/clock/scoring.py b/polylan_submitter/clock/scoring.py index 34f1a02..2a66c66 100644 --- a/polylan_submitter/clock/scoring.py +++ b/polylan_submitter/clock/scoring.py @@ -22,7 +22,8 @@ def _press_points_expression(): def ranked_players(event: Event): - """All users annotated with their live total points for this event and + """All users annotated with their live total `clock_points` (not `points`, + that one is the market balance field on CustomUser) for this event and DB-computed RANK(). Points only ever come from presses made in `event` - a player's history in another event never leaks into this leaderboard.""" from accounts.models import CustomUser @@ -32,6 +33,6 @@ def ranked_players(event: Event): Value(0.0), output_field=FloatField(), ) - return CustomUser.objects.annotate(points=points).annotate( - rank=Window(expression=Rank(), order_by=F("points").desc()) + return CustomUser.objects.annotate(clock_points=points).annotate( + rank=Window(expression=Rank(), order_by=F("clock_points").desc()) )