[bugfix] paging rel links (#2883)

* fix paging so it uses correct cursor query parameter name

* improved code comment

* whoops, flip the cursoring 🤦

* fix the broken test
This commit is contained in:
kim
2024-04-30 11:19:33 +01:00
committed by GitHub
parent bfc21e4850
commit 4f87ef246c
3 changed files with 49 additions and 26 deletions

View File

@ -23,26 +23,36 @@ package paging
func EitherMinID(minID, sinceID string) Boundary {
/*
Paging with `since_id` vs `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
+----------+ +----------+
| | | |
+----------+ +----------+
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 {