dd limit and offset pagination support to GET /flows/{flow_id}/runs#464
dd limit and offset pagination support to GET /flows/{flow_id}/runs#464Neroschizoid wants to merge 1 commit intoNetflix:masterfrom
Conversation
|
One thing to watch out with offset-based pagination here: on tables with concurrent inserts (common during foreach splits), rows shift between page requests which can cause duplicates or skipped records. Also offset degrades on deep pages since Postgres scans and discards N rows before returning results. Might be worth considering a cursor-based approach using ts_epoch or run_number instead. Also looks like invalid _limit values would hit the DB and return a raw 500 rather than a clean 400. |
Thanks for the recommendations, in my next commit i was looking into fixing the 500 status as for the cursor based approach, I would look into the query optimization to see how it plays out. |
Summary
This PR adds support for
limitandoffsetquery parameters to theGET /flows/{flow_id}/runsendpoint to enable pagination of runs.Changes
AsyncPostgresTable.get_recordsto support an optionaloffsetparameter.AsyncRunTablePostgres.get_all_runsto acceptlimitandoffset.RunApi.get_all_runsto:limitandoffsetfrom query parameters0ts_epoch DESC(latest runs first)Behavior
limit=0returns all runs (existing behavior preserved)limitandoffsetare clamped to0400errorBackward Compatibility
Testing
Tested manually using:
?limit=2?limit=2&offset=2?limit=0?limit=-5?limit=abcVerified: