Pagination (was: Re: [PATCH 1/3] REST: Integrate django-filter support)
stephen at that.guru
Mon Dec 12 23:34:04 AEDT 2016
On Mon, 2016-12-12 at 18:14 +1100, Andrew Donnellan wrote:
> On 21/11/16 14:17, Andrew Donnellan wrote:
> > On 21/11/16 11:39, Russell Currey wrote:
> > > Do you know if there's a way to get a reverse ordering of entries
> > > in
> > > the REST
> > > API? For example in the patches API each "page" has 30 entries,
> > > and
> > > you can get
> > > the latest page with ?page=last - but this isn't as nice as a
> > > reverse
> > > ordering
> > > of ids or dates. Do you know if there's a way to do this at
> > > present,
> > > or is that
> > > something that could be made available with filters?
> > I'd be kinda tempted to consider using cursor pagination for this,
> > which
> > Django REST Framework supports.
> > That's not a filter-related thing though.
> Stephen, any thoughts on this?
I don't think we support this yet but it would be easily added. I'm not
sure how well cursor pagination would map to of our endpoints, seeing
as we use simple, integer-based indexing for all ID fields. My personal
preference would be a 'direction=(asc|desc)' parameter, assuming we
don't really need to sort on different fields. If we did need to sort
then I'd opt for a combination of a 'sort=(date|name|submitter)'
parameter (for '/patches' - different values for other endpoints) and
'direction', but I'd also be fine with just 'sort' and a '-' prefix to
reverse things. Happy to take patches for any solution :)
While we're on the matter, would it be possible to take a look at the
patches in the 'series-api' work? There are a couple that still need at
least one reviewer before I'd be happy letting them in:
More information about the Patchwork