mirror of
https://github.com/etesync/server
synced 2024-12-27 09:48:24 +00:00
Filter by stoken: fix the done implementation for more functions
The done implementation wasn't great because it would indicate we are not done even when we are when the last chunk returned is exactly the size of limit.
This commit is contained in:
parent
0ce2e8d996
commit
c21c6af1d7
@ -288,13 +288,16 @@ class CollectionItemViewSet(BaseViewSet):
|
||||
iterator = get_object_or_404(queryset, uid=iterator)
|
||||
queryset = queryset.filter(id__lt=iterator.id)
|
||||
|
||||
queryset = queryset[:limit]
|
||||
serializer = CollectionItemRevisionSerializer(queryset, context=self.get_serializer_context(), many=True)
|
||||
result = list(queryset[:limit + 1])
|
||||
if len(result) < limit + 1:
|
||||
done = True
|
||||
else:
|
||||
done = False
|
||||
result = result[:-1]
|
||||
|
||||
# This is not the most efficient way of implementing this, but it's good enough
|
||||
done = len(queryset) < limit
|
||||
serializer = CollectionItemRevisionSerializer(result, context=self.get_serializer_context(), many=True)
|
||||
|
||||
last_item = len(queryset) > 0 and serializer.data[-1]
|
||||
last_item = len(result) > 0 and serializer.data[-1]
|
||||
|
||||
ret = {
|
||||
'data': serializer.data,
|
||||
@ -510,13 +513,16 @@ class InvitationBaseViewSet(BaseViewSet):
|
||||
iterator = get_object_or_404(queryset, uid=iterator)
|
||||
queryset = queryset.filter(id__gt=iterator.id)
|
||||
|
||||
queryset = queryset[:limit]
|
||||
serializer = self.get_serializer(queryset, many=True)
|
||||
result = list(queryset[:limit + 1])
|
||||
if len(result) < limit + 1:
|
||||
done = True
|
||||
else:
|
||||
done = False
|
||||
result = result[:-1]
|
||||
|
||||
# This is not the most efficient way of implementing this, but it's good enough
|
||||
done = len(queryset) < limit
|
||||
serializer = self.get_serializer(result, many=True)
|
||||
|
||||
last_item = len(queryset) > 0 and serializer.data[-1]
|
||||
last_item = len(result) > 0 and serializer.data[-1]
|
||||
|
||||
ret = {
|
||||
'data': serializer.data,
|
||||
|
Loading…
Reference in New Issue
Block a user