Paginate query responses and document assets#32
Conversation
|
/query needs either pagination, a limit on number of row returned, or a way to select fewer columns. Otherwise broad cutoffs like 0.80 can fail with a 500 code from response size |
|
The limit does not have to be 100 -- change it if you think it should be higher, before merging. |
|
Thanks for this @ejanalysis! Yes, the API needs to be more like an API.... I'm not sure capping at 100 or even 500 rows is a great solution. Pagination is, but it will take some development and testing. This, generated with the help of Gemini through a Google search, seems like the bones of what we want. We'd be adding a page parameter, then on each call to the endpoint, the API would do the whole calculation, returning the results corresponding to the requested page (e.g. if the limit is 100 per page, then page 2 would return results 101-200, or 100-199 depending on indexing). This example has |
Bring the query row-limit branch up to date with main (handoff endpoints, CORS, /assets mount, single-sourced base URL, Swagger @tag annotations). Conflict resolution: - rest_controller.r (/query roxygen): keep BOTH the row-limit description and main's `@tag Data` annotation; the row-limiting code (query_limit <- 100L) merged cleanly. - README.md: take main's richer Model/Base-URLs intro (drops the stale "three endpoints" one-liner); keep this branch's new "## Query" section (documents the 100-row limit) plus main's Handoff/CORS/Assets; drop this branch's now-stale root-path "## Assets" (main moved assets to /assets/<name>). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
I just assigned the rewrite (per your comments) and testing of this to Codex, so let's see what it can come up with. |
There was a problem hiding this comment.
Pull request overview
This PR updates the /query endpoint to support explicit pagination (page/limit) and returns a consistent { results, pagination } response envelope, with corresponding README documentation and new unit tests for the pagination helper/endpoint wrapper.
Changes:
- Added
pageandlimitparameters to/query, including input validation and HTTP 400 mapping for invalid pagination inputs. - Introduced
query_pagination.Rhelpers (paginate_query_results(),query_endpoint_response()) and wired them intorest_controller.r. - Documented the paginated
/queryresponse contract inREADME.mdand addedtestthatcoverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/test-query-pagination.R | Adds tests covering pagination behavior, validation, and 400 mapping for invalid inputs. |
| rest_controller.r | Wires /query to the new pagination-aware response helper and documents new params. |
| README.md | Documents /query pagination parameters and the {results, pagination} response envelope. |
| query_pagination.R | Implements pagination helpers, input validation, and endpoint response assembly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed the remaining review comments on #32. Changes pushed in — Codex |
Implement pagination for /query responses instead of a fixed first-page cap. Adds page and limit parameters, bounds limit at 500 rows per page, returns a consistent results plus pagination envelope, validates invalid pagination inputs with HTTP 400 responses, and documents the response contract in the README.\n\nAlso keeps the static assets route documentation from the original PR.