Repository navigation
Done
Labels
priority: lowLow prioritystatus: in progressCurrently being worked ontype: featureNew feature or requestworkload: hoursLikely takes hours to resolve
Milestone
Description
Problem
foca.utils.pagination pages by offset (offset/limit). Offsets skip or repeat items when items are added or deleted between two requests, so the services built on FOCA page their lists with opaque page tokens instead, each with its own code: cloud-registry (GET /failures, pageSize/pageToken), drs-filer (GET /objects, elixir-cloud-aai/drs-filer#140) and proWES (GET /runs, page_size/page_token). They differ in details (token format, validation, maximum page size), and each had to fix the same bugs (e.g., elixir-cloud-aai/cloud-registry#420: malformed tokens answered with 500).
Proposal
Add keyset ("page token") pagination to foca.utils.pagination, next to the offset helpers:
- Parse and check a page size against a configurable default and maximum (
400with the parameter named, without echoing the value). - Encode and decode opaque tokens for a stable sort key (e.g., MongoDB
_id, or a time plus_idas tie-breaker), with an exact check (re.fullmatch, see fix: schema patterns accept a trailing newline #797) and400for malformed tokens. - Build the MongoDB filter and sort for the next page, and the next token from the last item.
- Parameter names stay with the app (GA4GH APIs differ:
pageTokenvspage_token). - Docs in "Paginating lists"; then move cloud-registry, drs-filer and proWES to the helper in their own PRs.
Done when
- Tests: first, middle and last page; items added or deleted between pages; malformed and fabricated tokens; size bounds.
- Docs updated.
Metadata
Metadata
Assignees
Labels
priority: lowLow prioritystatus: in progressCurrently being worked ontype: featureNew feature or requestworkload: hoursLikely takes hours to resolve
Type
Projects
- StatusShow more project fieldsDone
Activity