Pagination integration proof of concept#3086
Pagination integration proof of concept#3086rtibbles merged 8 commits intolearningequality:unstablefrom
Conversation
Codecov Report
@@ Coverage Diff @@
## unstable #3086 +/- ##
============================================
- Coverage 86.13% 85.84% -0.30%
============================================
Files 305 298 -7
Lines 16455 15855 -600
============================================
- Hits 14173 13610 -563
+ Misses 2282 2245 -37
Continue to review full report at Codecov.
|
bjester
left a comment
There was a problem hiding this comment.
Does this cover sorting by annotated fields? I see pagination is now before annotation, but I don't see how sorting by an annotated field would get picked up. I noticed this use case in the AdminUser viewset where it annotates a field prior to pagination if the sorting requires that field. That appears to be removed here
To some extent, and it is now parallel to filtering in that regard. Any annotations that are required for filtering or sorting now need to be applied in the It's very possible that I missed something in my messing with the AdminUserViewset, can correct if some of the ordering is not working there now. I definitely think some improved documentation of the values viewset life cycle is a necessary corollary to this. |
|
I think it would be useful to have the paginator conditionally annotate the queryset if it detected sorting by an annotated field, to avoid unnecessary annotations which could slow down the un- |
I did check for that - the annotations only get put into the eventual query if they are part of the resulting values call. For the un-LIMIT-ed query, we do a |
Ah yes, that's Django magic not really performing what your code looks like it's doing. Thanks! |
bjester
left a comment
There was a problem hiding this comment.
Nice! Mostly just comments with only one likely important change for LIMIT_OFFSET_KEYS
Summary
Description of the change(s) you made
After numerous issues arising because of pagination, this creates a prototype to ensure full integration of both the ValuesViewset and the frontend resource layer with both ordering and pagination.
This means that we can use standard Django Rest Framework
orderingsyntax for specifying the ordering of results from the API (https://www.django-rest-framework.org/api-guide/filtering/#orderingfilter) and this will be properly interpreted by both the backend and the IndexedDBwherewrapper command.In addition, this adds support in the backend for PageNumberPagination to be added to any ValuesViewset class when needed, and to leverage the efficiency gains that were added specifically to the AdminChannel and AdminUser viewsets.
In the frontend it adds support for PageNumberPagination and LimitOffsetPagination for IndexedDB queries through
where.Manual verification steps performed
Checked all places that ordering and pagination are currently used:
whereand verified that pagination worked as expected)Screenshots (if applicable)
Does this introduce any tech-debt items?
Reviewer guidance
How can a reviewer test these changes?
Are there any risky areas that deserve extra testing?
References
Comments
Contributor's Checklist
PR process:
CHANGELOGlabel been added to this PR. Note: items with this label will be added to the CHANGELOG at a later timedocslabel has been added if this introduces a change that needs to be updated in the user docs?requirements.txtfiles also included in this PRStudio-specifc:
notranslateclass been added to elements that shouldn't be translated by Google Chrome's automatic translation feature (e.g. icons, user-generated text)pages,components, andlayoutsdirectories as described in the docsTesting:
Reviewer's Checklist
This section is for reviewers to fill out.
yarnandpip)