This repository has been archived by the owner on Mar 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
api: add optional resource count to list endpoints #358
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a custom DRF paginator which is based on CursorPaginator byt can optionally add a count of the number of results. This is disabled by default because doing a full count can be inefficient and isn't always needed. Add appropriate magic to make sure that the Swagger API documentation reflects the new change.
Make use of the new pagination class allowing all resource list views to optionally include a total resource count.
Allow the page size of list responses to be specified. This is to allow the case where one doesn't really care about the resources but one wants the count. In this case, one can just set page_size to 1. DRF diasallows setting page_size to 0.
rjw57
force-pushed
the
add-count-to-list-results
branch
from
October 12, 2018 14:35
3f31cbc
to
8cbda3a
Compare
Codecov Report
@@ Coverage Diff @@
## master #358 +/- ##
=========================================
- Coverage 91.28% 90.9% -0.39%
=========================================
Files 43 44 +1
Lines 1882 1924 +42
=========================================
+ Hits 1718 1749 +31
- Misses 164 175 +11
Continue to review full report at Codecov.
|
abrahammartin
suggested changes
Oct 15, 2018
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.
doesn't work
msb
previously approved these changes
Oct 15, 2018
Add tests which exercise include_count when the user is logged in.
@abrahammartin I think this is related to a Django bug. I've added a (failing) test case which triggers the bug. |
I've moved the page size functionality from this PR to #373. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As sketched in #350, we need an ability to get a count of resources matching a search. This PR extends the resource list endpoints in the following ways:
The page size cannot yet be limited to "0". Looking around the internets, this appears to be intentional; if the page size is zero the "next" links returned by the CursorPagination paginator become an infinite loop. This may or may not be a problem for us but, in any case, it is easy to add support for a zero page size later on if needs be.