proposal: paginate ListTasks RPC and task list page#1014
Conversation
|
@icholy-bot I think I want something like a pagination package which can hide some of these details that you have in the handler. |
|
Good call — pushed a revision that extracts the plumbing into a reusable The package is generic over the cursor type
The page, err := pagination.Parse[taskCursor](listTasksPaging, req.PageSize, req.PageToken)
// ... store.ListTasksPage(..., Limit: page.Limit()) ...
tasks, nextToken, err := pagination.Result(tasks, page, func(t *model.Task) taskCursor {
return taskCursor{CreatedAt: t.CreatedAt, ID: t.ID}
})Only the One placement question for you in the doc: |
Summary
Adds a design proposal for paginating the
ListTasksRPC and the task list page (webui/src/routes/tasks.index.tsx), per the linked issue. No implementation — just the proposal document inproposals/draft/.The proposed design uses keyset (cursor) pagination:
ListTasksRequestgainspage_size,page_token, andfilter;ListTasksResponsegainsnext_page_token.(created_at, id)of the last row; the SQL switches toORDER BY created_at DESC, id DESCwith a keyset predicate and a supporting partial index.useInfiniteQuerywith a debounced filter and a "Load more" control.Key decisions (keyset vs offset, server-side vs client-side search, why not the bare-
limitListExternalEventsconvention, "Load more" vs numbered pages) and open questions (default page size, total count, status filtering) are written up in the document for review.Closes #1012