Allow sorting by pinball score
This commit is contained in:
parent
55886eeec9
commit
f89c6cff30
|
@ -246,7 +246,7 @@ class PinballScore(models.Model):
|
||||||
|
|
||||||
# no history
|
# no history
|
||||||
|
|
||||||
MY_FIELDS = ['started_at', 'game_id', 'player', 'score']
|
MY_FIELDS = ['started_at', 'game_id', 'player', 'score', 'user']
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.started_at)
|
return str(self.started_at)
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ class TransactionSerializer(serializers.ModelSerializer):
|
||||||
# hide info for non-vetted members so someone sitting
|
# hide info for non-vetted members so someone sitting
|
||||||
# in our parking lot can't scrape all our info
|
# in our parking lot can't scrape all our info
|
||||||
class OtherMemberSerializer(serializers.ModelSerializer):
|
class OtherMemberSerializer(serializers.ModelSerializer):
|
||||||
|
pinball_score = serializers.IntegerField(required=False)
|
||||||
last_name = serializers.SerializerMethodField()
|
last_name = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -196,6 +197,7 @@ class OtherMemberSerializer(serializers.ModelSerializer):
|
||||||
'application_date',
|
'application_date',
|
||||||
'photo_small',
|
'photo_small',
|
||||||
'public_bio',
|
'public_bio',
|
||||||
|
'pinball_score',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_last_name(self, obj):
|
def get_last_name(self, obj):
|
||||||
|
@ -206,6 +208,8 @@ class OtherMemberSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
# vetted member viewing other members
|
# vetted member viewing other members
|
||||||
class VettedOtherMemberSerializer(serializers.ModelSerializer):
|
class VettedOtherMemberSerializer(serializers.ModelSerializer):
|
||||||
|
pinball_score = serializers.IntegerField(required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Member
|
model = models.Member
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -218,6 +222,7 @@ class VettedOtherMemberSerializer(serializers.ModelSerializer):
|
||||||
'photo_small',
|
'photo_small',
|
||||||
'photo_large',
|
'photo_large',
|
||||||
'public_bio',
|
'public_bio',
|
||||||
|
'pinball_score',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,10 @@ class SearchViewSet(Base, Retrieve):
|
||||||
).exclude(last_scanned__isnull=True).order_by('-last_scanned')
|
).exclude(last_scanned__isnull=True).order_by('-last_scanned')
|
||||||
else:
|
else:
|
||||||
queryset = []
|
queryset = []
|
||||||
|
elif sort == 'pinball_score':
|
||||||
|
queryset = queryset.annotate(
|
||||||
|
pinball_score=Max('user__scores__score'),
|
||||||
|
).exclude(pinball_score__isnull=True).order_by('-pinball_score')
|
||||||
elif sort == 'everyone':
|
elif sort == 'everyone':
|
||||||
queryset = queryset.annotate(Count('user__transactions')).order_by('-user__transactions__count', 'id')
|
queryset = queryset.annotate(Count('user__transactions')).order_by('-user__transactions__count', 'id')
|
||||||
elif sort == 'best_looking':
|
elif sort == 'best_looking':
|
||||||
|
|
|
@ -11,6 +11,7 @@ import AbortController from 'abort-controller';
|
||||||
const memberSorts = {
|
const memberSorts = {
|
||||||
recently_vetted: 'Recently Vetted',
|
recently_vetted: 'Recently Vetted',
|
||||||
last_scanned: 'Last Scanned',
|
last_scanned: 'Last Scanned',
|
||||||
|
pinball_score: 'Pinball Score',
|
||||||
newest_active: 'Newest',
|
newest_active: 'Newest',
|
||||||
//newest_overall: 'Newest Overall',
|
//newest_overall: 'Newest Overall',
|
||||||
oldest_active: 'Oldest',
|
oldest_active: 'Oldest',
|
||||||
|
@ -227,8 +228,17 @@ export function Members(props) {
|
||||||
<Icon name='circle' color={statusColor[x.member.status]} />
|
<Icon name='circle' color={statusColor[x.member.status]} />
|
||||||
{x.member.preferred_name} {x.member.last_name}
|
{x.member.preferred_name} {x.member.last_name}
|
||||||
</Item.Header>
|
</Item.Header>
|
||||||
<Item.Description>Status: {x.member.status || 'Unknown'}</Item.Description>
|
{sort === 'pinball_score' ?
|
||||||
<Item.Description>Joined: {x.member.application_date || 'Unknown'}</Item.Description>
|
<>
|
||||||
|
<Item.Description>Score: {x.member.pinball_score || 'Unknown'}</Item.Description>
|
||||||
|
<Item.Description>Rank: {i === 0 ? 'Pinball Wizard' : 'Not the Pinball Wizard'}</Item.Description>
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<Item.Description>Status: {x.member.status || 'Unknown'}</Item.Description>
|
||||||
|
<Item.Description>Joined: {x.member.application_date || 'Unknown'}</Item.Description>
|
||||||
|
</>
|
||||||
|
}
|
||||||
<Item.Description>ID: {x.member.id}</Item.Description>
|
<Item.Description>ID: {x.member.id}</Item.Description>
|
||||||
</Item.Content>
|
</Item.Content>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user