Pagination
This PR introduces pagination for lists of sessions (user specific: owned and visited), interposed questions and free text answers and skill questions. While the first three are paginated through the database, skill questions are paginated in memory so caching is still possible.
Frontend usage
To enable pagination, new HTTP headers based on RFC 7233 have been introduced:
Request: Range: items=<start>-<end>
, e.g. Range: items=0-9
Response: Content-Range: items <start>-<end>/<total>
, e.g. Content-Range: items 0-9/42
Since it is not possible to determine the total count of items via CouchDB w/o performance losses, it is currently only set accurately for skill questions. In other cases total
is set to -1
.
Backend usage
Pagination support can be added to controllers by extending the newly introduced PaginationController
. Additionally, applicable methods have to be marked with the @Pagination
annotation so the Range
header is parsed and the Content-Range
header is set for responses. Pagination parameters are accessible in the controller through the offset
and limit
fields. If pagination on the DBAL is not possible, lists can be wrapped with PaginationListDecorator<T>
to enable in memory pagination.
TODOs
-
Testing -
Review -
Javadoc