Repository navigation
Conversation
Add sort_order=asc|desc and created_after/created_before (RFC 3339) query parameters to GET /api/jobs. Explicit values override the existing per-state defaults while the old defaults are preserved when no sort order is given. The created-at range is applied through JobListParams.Where, which works across PostgreSQL and SQLite. Expose both in the UI with a newest/oldest toggle and a created-at range popover in the job list header. The search params are retained across navigation and included in the jobs query key so cancel, delete, and retry mutations refresh the active result set. Adds backend coverage for sort order and created-at filtering.
Cover the sort order and created-at range filters at the component and route layers: the JobList controls report changes, the search schema accepts asc/desc and timestamps, the active query key carries all three filters, and the route callbacks round-trip values into search.
The Time Range label wrapped to two lines when the job search input took up the remaining header width.
|
Thanks @mheers! Blake wants to take a look at a couple things related to index performance before bringing this in, but in the meantime, would you mind signing the CLA? https://github.com/riverqueue/rivercla |
bgentry
left a comment
There was a problem hiding this comment.
Thanks for the PR! From an initial review pass, the main issue is that filtering by created_at makes this fall back to a sequential scan because there's no relevant index to be used. This doesn't matter much at small scale, but in large prod deployments it could cause some real load issues if somebody leaves open this view with frequent auto refresh enabled.
I'm also inclined to put the filters directly in the main river repo. Originally we were only putting filters/sorts/etc in there that we knew could be done efficiently, but as usage grew we accepted that it was still better to include more flexible options even if they weren't necessarily going to be efficient. That way people can still build custom tooling that leverages the query APIs for infrequent use cases where the perf hit doesn't matter. So I think we can still move these filters over there in a standalone PR.
Meanwhile, @brandur and I should probably discuss what we want to do about UI use cases that we can't serve efficiently without adding more indexes (which we generally don't want to force on everyone due to impact on throughput, table sizes, etc).
Just to clarify Blake: you consider this a blocker? |
Adds a newest/oldest toggle and a created-at range filter to the Jobs pane.
GET /api/jobsacceptssort_order=asc|desc,created_after, andcreated_before(RFC 3339). An explicit sort order overrides the existing per-state defaults; whensort_orderis omitted, the current defaults stay as they are.JobListParams.Where("created_at >= @created_after", ...), which is applied by both the PostgreSQL and SQLite drivers.Screenshots
Newest-first sort:
Created-at range filter:
Open question:
Wherevs. a River core APITag filtering landed upstream through a first-class
JobListParamsAPI (riverqueue/river#1339), while this usesJobListParams.Wherewith named args.Whereis applied by both drivers, and River has no existing created-at filter or ordering field.Would you prefer that I add
CreatedAfter/CreatedBefore(and possibly a created-at ordering field) toriverqueue/riverfirst and pin to it, or is theWhereapproach acceptable here?Notes
JobListOrderByTime, so it orders by the state-specific timestamp (scheduled_at,attempted_at, orfinalized_atdepending on state). The created-at range filter is independent of that.JobSearchfilter grammar (for examplecreated:) instead if that fits the direction better.