Return all high scores from API

This commit is contained in:
Tanner Collin 2023-02-15 00:18:30 +00:00
parent 64e328c137
commit b47c773b16
2 changed files with 3 additions and 2 deletions

View File

@ -1490,7 +1490,7 @@ class PinballViewSet(Base):
members = models.Member.objects.all() members = models.Member.objects.all()
members = members.annotate( members = members.annotate(
pinball_score=Max('user__scores__score'), 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 = [] scores = []
@ -1498,6 +1498,7 @@ class PinballViewSet(Base):
scores.append(dict( scores.append(dict(
name=member.preferred_name + ' ' + member.last_name[0], name=member.preferred_name + ' ' + member.last_name[0],
score=member.pinball_score, score=member.pinball_score,
member_id=member.id,
)) ))
return Response(scores) return Response(scores)

View File

@ -112,7 +112,7 @@ export function DisplayScores(props) {
<> <>
<Header size='large'>Pinball High Scores</Header> <Header size='large'>Pinball High Scores</Header>
{scores && scores.map((x, i) => {scores && scores.slice(0, 5).map((x, i) =>
<div key={i}> <div key={i}>
<Header size='medium'>#{i+1} {x.name}. {i === 0 ? '👑' : ''}</Header> <Header size='medium'>#{i+1} {x.name}. {i === 0 ? '👑' : ''}</Header>
<p>{x.score.toLocaleString()}</p> <p>{x.score.toLocaleString()}</p>