From 5fc5b01e1dfbd1c3615bf6ef5cdb1841c6c10975 Mon Sep 17 00:00:00 2001 From: Ivan Gorshkov Date: Fri, 22 Aug 2025 17:04:35 +0100 Subject: [PATCH 1/3] adding empty string for cursor pagination endpoint --- internal/pagination/service.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/pagination/service.go b/internal/pagination/service.go index 4f096f1..13654be 100644 --- a/internal/pagination/service.go +++ b/internal/pagination/service.go @@ -229,6 +229,12 @@ func HandleURL(w http.ResponseWriter, r *http.Request) { } func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) { + endCursor := r.FormValue("endCursor") + handleNonNumericCursorWithEndCursor(w, r, endCursor) +} + + +func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, endCursor string) { limit := 15 queryCursor := r.FormValue("cursor") @@ -249,10 +255,16 @@ func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) { res.ResultArray = append(res.ResultArray, unhash(i)) } - // output cursor to $.cursor in addition to $.resultArray[(@.length-1)] if len(res.ResultArray) == limit { cursor, _ := res.ResultArray[len(res.ResultArray)-1].(string) res.Cursor = &cursor + } else if endCursor != "" { + if endCursor == "#emptyString" { + emptyCursor := "" + res.Cursor = &emptyCursor + } else { + res.Cursor = &endCursor + } } w.Header().Set("Content-Type", "application/json") From 50b5808b0dc7fad2a5ba667a8150a9b6bafbf6b8 Mon Sep 17 00:00:00 2001 From: Ivan Gorshkov Date: Tue, 26 Aug 2025 17:05:02 +0100 Subject: [PATCH 2/3] cleaned up cursor logic --- internal/pagination/service.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/pagination/service.go b/internal/pagination/service.go index 13654be..716feae 100644 --- a/internal/pagination/service.go +++ b/internal/pagination/service.go @@ -229,12 +229,21 @@ func HandleURL(w http.ResponseWriter, r *http.Request) { } func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) { - endCursor := r.FormValue("endCursor") + vals, ok := r.URL.Query()["endCursor"] + var endCursor *string + if ok && len(vals) > 0 { + endCursor = &vals[0] + } handleNonNumericCursorWithEndCursor(w, r, endCursor) } -func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, endCursor string) { +// handleNonNumericCursorWithEndCursor handles cursor-based pagination with non-numeric cursors. +// Three cursor behaviors: +// 1. If results fill the page limit, cursor is set to the last item +// 2. If endCursor parameter is provided (including empty string), use that as cursor +// 3. If no endCursor parameter and partial results, no cursor is set +func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, endCursor *string) { limit := 15 queryCursor := r.FormValue("cursor") @@ -258,13 +267,8 @@ func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, if len(res.ResultArray) == limit { cursor, _ := res.ResultArray[len(res.ResultArray)-1].(string) res.Cursor = &cursor - } else if endCursor != "" { - if endCursor == "#emptyString" { - emptyCursor := "" - res.Cursor = &emptyCursor - } else { - res.Cursor = &endCursor - } + } else if endCursor != nil { + res.Cursor = endCursor } w.Header().Set("Content-Type", "application/json") From 97615b9105c4b52fd612d3fd43d9ca5c8c4e2054 Mon Sep 17 00:00:00 2001 From: Ivan Gorshkov Date: Wed, 27 Aug 2025 17:04:17 +0100 Subject: [PATCH 3/3] refactoring --- internal/pagination/service.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/pagination/service.go b/internal/pagination/service.go index 716feae..1c73ffb 100644 --- a/internal/pagination/service.go +++ b/internal/pagination/service.go @@ -234,16 +234,7 @@ func HandleNonNumericCursor(w http.ResponseWriter, r *http.Request) { if ok && len(vals) > 0 { endCursor = &vals[0] } - handleNonNumericCursorWithEndCursor(w, r, endCursor) -} - -// handleNonNumericCursorWithEndCursor handles cursor-based pagination with non-numeric cursors. -// Three cursor behaviors: -// 1. If results fill the page limit, cursor is set to the last item -// 2. If endCursor parameter is provided (including empty string), use that as cursor -// 3. If no endCursor parameter and partial results, no cursor is set -func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, endCursor *string) { limit := 15 queryCursor := r.FormValue("cursor") @@ -278,6 +269,7 @@ func handleNonNumericCursorWithEndCursor(w http.ResponseWriter, r *http.Request, } } + func HandleLimitOffsetDeepOutputsPage(w http.ResponseWriter, r *http.Request) { queryLimit := r.FormValue("limit") queryPage := r.FormValue("page")