Fix filter by cstoken function to not fetch twice.

This commit is contained in:
Tom Hacohen 2020-05-19 17:29:54 +03:00
parent c63210fe77
commit 9bbb7ef3d7

View File

@ -85,8 +85,7 @@ class BaseViewSet(viewsets.ModelViewSet):
cstoken_rev = self.get_cstoken_rev(request) cstoken_rev = self.get_cstoken_rev(request)
if cstoken_rev is not None: if cstoken_rev is not None:
last_rev = get_object_or_404(CollectionItemRevision.objects.all(), uid=cstoken_rev.uid) filter_by = {cstoken_id_field + '__gt': cstoken_rev.id}
filter_by = {cstoken_id_field + '__gt': last_rev.id}
queryset = queryset.filter(**filter_by) queryset = queryset.filter(**filter_by)
cstoken = cstoken_rev.uid cstoken = cstoken_rev.uid
else: else: