Skip to content
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

Paginate Site Evaluations endpoint #109

Merged
merged 4 commits into from
Nov 8, 2022
Merged

Conversation

mvandenburgh
Copy link
Member

Closes #89

Unfortunately, DRF's default pagination mechanism doesn't completely work here. DRF's paginate_queryset method returns a list instead of a QuerySet, and thus is intended to be called after all other queries have been made. Unfortunately, the end result of the queries made in the site evaluations endpoint is not a QuerySet but a dict, due to the use of .aggregate(). So, there doesn't appear to be a way to use DRF's native pagination methods here; instead, I've dropped down a level to Django's native Paginator, which the DRF one uses under the hood.

I went ahead and configured pagination for DRF anyway in settings.py, and also refer to the PAGE_SIZE setting in the manual pagination code I wrote so it will be consistent with any DRF-paginated endpoints we have in the future.

@mvandenburgh mvandenburgh requested a review from mcovalt November 2, 2022 18:26
Copy link
Contributor

@mcovalt mcovalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! @mvandenburgh be sure to review my changes in 0875f7d. Also note the subsequent suppression of MyPy warning in ead97b5.

The commit 0875f7d changes the behavior slightly so that count, timerange, and bbox cover the whole object list, rather than the paginated subset. Unfortunately, my change brings us to two queries that I hope we can reduce to just one in the future with a Subquery.

@mvandenburgh
Copy link
Member Author

Changes look good to me, thanks!

@mvandenburgh mvandenburgh merged commit c29e7a7 into phase-ii Nov 8, 2022
@mvandenburgh mvandenburgh deleted the paginate-site-evaluations branch November 8, 2022 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants