From b47c773b164ea2ea9e9b20a66714889b54aa22e8 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 15 Feb 2023 00:18:30 +0000 Subject: [PATCH] Return all high scores from API --- apiserver/apiserver/api/views.py | 3 ++- webclient/src/Display.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 7a8be82..f7b92e0 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -1490,7 +1490,7 @@ class PinballViewSet(Base): members = models.Member.objects.all() members = members.annotate( pinball_score=Max('user__scores__score'), - ).exclude(pinball_score__isnull=True).order_by('-pinball_score')[:5] + ).exclude(pinball_score__isnull=True).order_by('-pinball_score') scores = [] @@ -1498,6 +1498,7 @@ class PinballViewSet(Base): scores.append(dict( name=member.preferred_name + ' ' + member.last_name[0], score=member.pinball_score, + member_id=member.id, )) return Response(scores) diff --git a/webclient/src/Display.js b/webclient/src/Display.js index 33fdeb1..92bfdf0 100644 --- a/webclient/src/Display.js +++ b/webclient/src/Display.js @@ -112,7 +112,7 @@ export function DisplayScores(props) { <>
Pinball High Scores
- {scores && scores.map((x, i) => + {scores && scores.slice(0, 5).map((x, i) =>
#{i+1} — {x.name}. {i === 0 ? '👑' : ''}

{x.score.toLocaleString()}