-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update next be a complete string url #4527
base: master
Are you sure you want to change the base?
Conversation
09f25e1
to
21f233d
Compare
21f233d
to
75f221e
Compare
if not self.page.has_next(): | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is has_next calculated here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SearchAfterPagination
extends PageNumberPagination
from django_elasticsearch_dsl_drf.pagination
PageNumberPagination
extends pagination.PageNumberPagination
from rest_framework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but that does not answer how it will fit in with SearchAfter pagination where the next is determined from sort values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def has_next(self):
return self.number < self.paginator.num_pages
The has_next
method checks if there are additional pages available by comparing the current page number (self.number
) with the total number of pages (self.paginator.num_pages
).
num_pages: Calculates the total number of pages based on the total count of objects (self.count), adjusted for orphans, and divided by per_page. It uses ceil to ensure partial pages are counted as full pages.
count: Determines the total number of objects. If the dataset has a callable count method (e.g., a QuerySet in Django), it uses that for efficiency. Otherwise, it defaults to the length of the object list.
References:
- https://github.com/django/django/blob/main/django/core/paginator.py#L205
- https://github.com/django/django/blob/main/django/core/paginator.py#L114
The current implementation does not include anything that should break the has_next
calculation for search_after pagination in Elasticsearch
PROD-4266
Update
next
be a complete string url (like v1) rather than a list in /api/v2/search/all