Remove duplicates from last scanned list

This commit is contained in:
Tanner Collin 2022-04-24 00:21:12 +00:00
parent 5a30f60d6e
commit 33aaf68c5e

View File

@ -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':