From 118a99aedd0ac077bcfd661761d1383c4ef70c3d Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 24 Aug 2022 21:27:24 +0000 Subject: [PATCH] Fix sorting by breaking ties --- apiserver/apiserver/api/views.py | 22 +++++++++++----------- webclient/src/Transactions.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index c722dee..b73dd34 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -97,33 +97,33 @@ class SearchViewSet(Base, Retrieve): elif self.action == 'create': if sort == 'recently_vetted': queryset = queryset.filter(vetted_date__isnull=False) - queryset = queryset.order_by('-vetted_date') + queryset = queryset.order_by('-vetted_date', '-id') elif sort == 'newest_active': queryset = queryset.filter(paused_date__isnull=True) - queryset = queryset.order_by('-application_date') + queryset = queryset.order_by('-application_date', '-id') elif sort == 'newest_overall': - queryset = queryset.order_by('-application_date') + queryset = queryset.order_by('-application_date', '-id') elif sort == 'oldest_active': queryset = queryset.filter(paused_date__isnull=True) - queryset = queryset.order_by('application_date') + queryset = queryset.order_by('application_date', 'id') elif sort == 'oldest_overall': queryset = queryset.filter(application_date__isnull=False) - queryset = queryset.order_by('application_date') + queryset = queryset.order_by('application_date', 'id') elif sort == 'recently_inactive': queryset = queryset.filter(paused_date__isnull=False) queryset = queryset.order_by('-paused_date') elif sort == 'is_director': queryset = queryset.filter(is_director=True) - queryset = queryset.order_by('application_date') + queryset = queryset.order_by('application_date', 'id') elif sort == 'is_instructor': queryset = queryset.filter(paused_date__isnull=True, is_instructor=True) - queryset = queryset.order_by('application_date') + queryset = queryset.order_by('application_date', 'id') elif sort == 'due': queryset = queryset.filter(status='Due') - queryset = queryset.order_by('expire_date') + queryset = queryset.order_by('expire_date', 'id') elif sort == 'overdue': queryset = queryset.filter(status='Overdue') - queryset = queryset.order_by('expire_date') + queryset = queryset.order_by('expire_date', 'id') elif sort == 'last_scanned': if self.request.user.member.allow_last_scanned: queryset = queryset.filter(allow_last_scanned=True) @@ -133,7 +133,7 @@ class SearchViewSet(Base, Retrieve): else: queryset = [] elif sort == 'everyone': - queryset = queryset.annotate(Count('user__transactions')).order_by('-user__transactions__count') + queryset = queryset.annotate(Count('user__transactions')).order_by('-user__transactions__count', 'id') elif sort == 'best_looking': queryset = [] @@ -984,7 +984,7 @@ class VettingViewSet(Base, List): queryset = queryset.filter(vetted_date__isnull=True) queryset = queryset.filter(current_start_date__lte=four_weeks_ago) - return queryset.order_by('-current_start_date') + return queryset.order_by('-current_start_date', '-id') class UsageViewSet(Base): diff --git a/webclient/src/Transactions.js b/webclient/src/Transactions.js index 5ba5c54..1c1226b 100644 --- a/webclient/src/Transactions.js +++ b/webclient/src/Transactions.js @@ -290,7 +290,7 @@ export function TransactionList(props) { {transactions.length ? - transactions.slice().sort((a, b) => a.date < b.date ? 1 : -1).map(x => + transactions.map(x => {moment(x.date).format('ll')}