Merge branch 'sort_score'

This commit is contained in:
Tanner Collin 2023-01-17 23:11:29 +00:00
commit efb29d4254
4 changed files with 22 additions and 3 deletions

View File

@ -246,7 +246,7 @@ class PinballScore(models.Model):
# no history
MY_FIELDS = ['started_at', 'game_id', 'player', 'score']
MY_FIELDS = ['started_at', 'game_id', 'player', 'score', 'user']
def __str__(self):
return str(self.started_at)

View File

@ -183,6 +183,7 @@ class TransactionSerializer(serializers.ModelSerializer):
# hide info for non-vetted members so someone sitting
# in our parking lot can't scrape all our info
class OtherMemberSerializer(serializers.ModelSerializer):
pinball_score = serializers.IntegerField(required=False)
last_name = serializers.SerializerMethodField()
class Meta:
@ -196,6 +197,7 @@ class OtherMemberSerializer(serializers.ModelSerializer):
'application_date',
'photo_small',
'public_bio',
'pinball_score',
]
def get_last_name(self, obj):
@ -206,6 +208,8 @@ class OtherMemberSerializer(serializers.ModelSerializer):
# vetted member viewing other members
class VettedOtherMemberSerializer(serializers.ModelSerializer):
pinball_score = serializers.IntegerField(required=False)
class Meta:
model = models.Member
fields = [
@ -218,6 +222,7 @@ class VettedOtherMemberSerializer(serializers.ModelSerializer):
'photo_small',
'photo_large',
'public_bio',
'pinball_score',
]

View File

@ -132,6 +132,10 @@ class SearchViewSet(Base, Retrieve):
).exclude(last_scanned__isnull=True).order_by('-last_scanned')
else:
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':
queryset = queryset.annotate(Count('user__transactions')).order_by('-user__transactions__count', 'id')
elif sort == 'best_looking':

View File

@ -11,6 +11,7 @@ import AbortController from 'abort-controller';
const memberSorts = {
recently_vetted: 'Recently Vetted',
last_scanned: 'Last Scanned',
pinball_score: 'Pinball Score',
newest_active: 'Newest',
//newest_overall: 'Newest Overall',
oldest_active: 'Oldest',
@ -227,8 +228,17 @@ export function Members(props) {
<Icon name='circle' color={statusColor[x.member.status]} />
{x.member.preferred_name} {x.member.last_name}
</Item.Header>
<Item.Description>Status: {x.member.status || 'Unknown'}</Item.Description>
<Item.Description>Joined: {x.member.application_date || 'Unknown'}</Item.Description>
{sort === 'pinball_score' ?
<>
<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.Content>
</Item>