Add limit/offset/order query params to table_view#61
Open
amyleesterling wants to merge 1 commit intoCAVEconnectome:masterfrom
Open
Add limit/offset/order query params to table_view#61amyleesterling wants to merge 1 commit intoCAVEconnectome:masterfrom
amyleesterling wants to merge 1 commit intoCAVEconnectome:masterfrom
Conversation
The table view was hardcoded to render the first 15 rows in default insertion order with no URL params for sorting or paging, which made it impossible to verify newly-written annotations (largest ids) or to browse a table past row 15 from the UI. Accept three optional query params on table_view, all backward compatible (a parameterless URL still returns the first 15 rows ascending): limit int default 15, clamped to [1, 500] offset int default 0, clamped to [0, inf) order str default "asc", "asc" or "desc" on Model.id Bad values fall back to the corresponding default rather than 500ing. The template gains "Showing rows N-M of TOTAL" plus prev / next / toggle-order links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/annotation/views/aligned_volume/<av>/table/<t>is hardcoded to render the first 15 rows of every annotation table in default insertion order and exposes no URL params for sorting or paging:This makes the view unusable for two common workflows:
id, but the view only ever shows ids 1–15, so users can't see what they just inserted without dropping to the API.Fix
Accept three optional query params on
table_view:limit[1, 500]to cap I/Ooffset[0, ∞)orderascascordesconModel.idDefaults preserve current behavior exactly: a parameterless URL still returns the first 15 rows in ascending id order. The template gains a "Showing rows N–M of TOTAL" line plus prev / next / toggle-order links.
Verification
After deploy, on a table with N rows (e.g. ~480):
?limit=20&offset=460&order=asc— last 20 rows of the table.?limit=10&order=desc— newest 10 rows (most recent writes first).A bad value (e.g.
?limit=abc,?offset=-5,?order=sideways) falls back to the corresponding default rather than 500ing.Risk
Minimal. Default URL is byte-identical to current behavior. The only new I/O path is
.offset(N).limit(M)against the same indexedidcolumn the table is already sorted on, capped at 500 rows per request.auth_requires_permissiondecorator is untouched, so authn/authz semantics are unchanged.fix_wkb_columns(df)still runs on the post-paged result.Independent of the materializer pyarrow (
pa.default_serialization_context) bug and the recently-merged CORS change on the Flask app — neither is touched here.