From d7928e7578c6004003601891d940915994a3b644 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 3 Jun 2023 19:02:58 +0000 Subject: [PATCH] Allow sorting members by storage --- apiserver/apiserver/api/views.py | 4 ++++ webclient/src/Members.js | 1 + 2 files changed, 5 insertions(+) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 227bbed..41424bd 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -135,6 +135,10 @@ class SearchViewSet(Base, Retrieve): queryset = queryset.annotate( pinball_score=Max('user__scores__score'), ).exclude(pinball_score__isnull=True).order_by('-pinball_score') + elif sort == 'storage': + queryset = queryset.annotate( + storage_count=Count('user__storage'), + ).exclude(storage_count=0).order_by('-storage_count', 'id') elif sort == 'everyone': queryset = queryset.annotate( protocoin_sum=Sum('user__transactions__protocoin'), diff --git a/webclient/src/Members.js b/webclient/src/Members.js index 0f34da9..e2ecf54 100644 --- a/webclient/src/Members.js +++ b/webclient/src/Members.js @@ -22,6 +22,7 @@ const memberSorts = { is_instructor: 'Instructors', due: 'Due', overdue: 'Overdue', + storage: 'Storage', everyone: 'Everyone', };