From 33aaf68c5e9a4f66be12ed57433f44322e0fc60f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 24 Apr 2022 00:21:12 +0000 Subject: [PATCH] Remove duplicates from last scanned list --- apiserver/apiserver/api/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 37ed44c..170eebf 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -124,7 +124,9 @@ class SearchViewSet(Base, Retrieve): elif sort == 'last_scanned': if self.request.user.member.allow_last_scanned: queryset = queryset.filter(allow_last_scanned=True) - queryset = queryset.order_by('-user__cards__last_seen') + queryset = queryset.annotate( + last_scanned=Max('user__cards__last_seen'), + ).exclude(last_scanned__isnull=True).order_by('-last_scanned') else: queryset = [] elif sort == 'everyone':