DM-48173: Add abstraction for counted paginated queries #357
+243
−20
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.
PaginatedQueryRunner
has a separatequery_count
method to return the count, but since the total entry count isn't included in thePaginatedList
data structure, it's annoying to pass between components of a service. Either the result plus the count have to be returned as a tuple, or the service has to add its own data structure to wrapPaginatedList
.Avoid this by introducing a
CountedPaginatedQueryRunner
and a correspondingCountedPaginatedList
that always includes acount
attribute. This can be used by services such as Gafaelfawr that always want to count the total number of entries, either because the table is small or because the count can always be satisfied from the table indices.