inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 62 forks source link

views: support "from" parameter in addition to "page" for use with infinite scroll #258

Closed lnielsen closed 5 years ago

lnielsen commented 5 years ago

Trying to implement an infinite scroll with the Invenio REST API is somewhat complicated from the fact that you need to provide page + size parameters. Would be easier if it was from and size. Also, it would be useful to be able to turn off aggregations for all but the first request (when in an infinite scroll). Via Cottage Labs

lnielsen commented 5 years ago

Needs a change to views:RecordsListResource.get() with something along the lines of:

size = request.values.get('size', default_results_size, type=int)
page = request.values.get('page', None, type=int)
from = request.values.get('from', None, type=int)

if from is not None and page is not None:
    abort(400, ... explain ...)

if page is not None:
    from = page * size

if from is None:
    from = 0

if from < 0:
    abort()

if size < 1:
    abort()