From 4f87ef246cc15d2b4a3effb3dff5cf3ece9a44b3 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:19:33 +0100 Subject: [bugfix] paging rel links (#2883) * fix paging so it uses correct cursor query parameter name * improved code comment * whoops, flip the cursoring :facepalm: * fix the broken test --- internal/paging/boundary.go | 50 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'internal/paging/boundary.go') diff --git a/internal/paging/boundary.go b/internal/paging/boundary.go index 83d265515..bf4508aff 100644 --- a/internal/paging/boundary.go +++ b/internal/paging/boundary.go @@ -23,26 +23,36 @@ package paging func EitherMinID(minID, sinceID string) Boundary { /* - Paging with `since_id` vs `min_id`: - - limit = 4 limit = 4 - +----------+ +----------+ - max_id--> |xxxxxxxxxx| | | <-- max_id - +----------+ +----------+ - |xxxxxxxxxx| | | - +----------+ +----------+ - |xxxxxxxxxx| | | - +----------+ +----------+ - |xxxxxxxxxx| |xxxxxxxxxx| - +----------+ +----------+ - | | |xxxxxxxxxx| - +----------+ +----------+ - | | |xxxxxxxxxx| - +----------+ +----------+ - since_id--> | | |xxxxxxxxxx| <-- min_id - +----------+ +----------+ - | | | | - +----------+ +----------+ + Paging with `since_id` vs `min_id`: + + limit = 4 limit = 4 + +----------+ +----------+ + max_id--> |xxxxxxxxxx| | | <-- max_id + +----------+ +----------+ + |xxxxxxxxxx| | | + +----------+ +----------+ + |xxxxxxxxxx| | | + +----------+ +----------+ + |xxxxxxxxxx| |xxxxxxxxxx| + +----------+ +----------+ + | | |xxxxxxxxxx| + +----------+ +----------+ + | | |xxxxxxxxxx| + +----------+ +----------+ + since_id--> | | |xxxxxxxxxx| <-- min_id + +----------+ +----------+ + | | | | + +----------+ +----------+ + + To sum it up in words: + + when paging with since_id, max_id is used as + the cursor value, and since_id provides a + limiting value to the results. + + when paging with min_id, min_id is used as + the cursor value, and max_id provides a + limiting value to the results. */ switch { -- cgit v1.2.3