Skip to content

Commit dfe3d7f

Browse files
committed
remove the limit from FilterBasedOnCursor
1 parent d99ce43 commit dfe3d7f

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

packages/api/internal/handlers/sandboxes_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ func (a *APIStore) GetV2Sandboxes(c *gin.Context, params api.GetV2SandboxesParam
160160
// Set the total (before we apply the limit, but already with all filters)
161161
c.Header("X-Total-Running", strconv.Itoa(len(runningSandboxList)))
162162

163-
// Filter based on cursor and limit
164-
runningSandboxList = utils.FilterBasedOnCursor(runningSandboxList, cursorTime, cursorID, limit)
163+
// Filter based on cursor
164+
runningSandboxList = utils.FilterBasedOnCursor(runningSandboxList, cursorTime, cursorID)
165165

166166
sandboxes = append(sandboxes, runningSandboxList...)
167167
}
@@ -177,7 +177,7 @@ func (a *APIStore) GetV2Sandboxes(c *gin.Context, params api.GetV2SandboxesParam
177177

178178
pausingSandboxList := instanceInfoToPaginatedSandboxes(sandboxesInCache[instance.StatePausing])
179179
pausingSandboxList = utils.FilterSandboxesOnMetadata(pausingSandboxList, metadataFilter)
180-
pausingSandboxList = utils.FilterBasedOnCursor(pausingSandboxList, cursorTime, cursorID, limit)
180+
pausingSandboxList = utils.FilterBasedOnCursor(pausingSandboxList, cursorTime, cursorID)
181181

182182
sandboxes = append(sandboxes, pausedSandboxList...)
183183
sandboxes = append(sandboxes, pausingSandboxList...)

packages/api/internal/utils/sandboxes_list.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func ParseCursor(cursor string) (time.Time, string, error) {
7676
return cursorTime, parts[1], nil
7777
}
7878

79-
func FilterBasedOnCursor(sandboxes []PaginatedSandbox, cursorTime time.Time, cursorID string, limit int32) []PaginatedSandbox {
79+
func FilterBasedOnCursor(sandboxes []PaginatedSandbox, cursorTime time.Time, cursorID string) []PaginatedSandbox {
8080
// Apply cursor-based filtering if cursor is provided
8181
var filteredSandboxes []PaginatedSandbox
8282
for _, sandbox := range sandboxes {
@@ -87,17 +87,8 @@ func FilterBasedOnCursor(sandboxes []PaginatedSandbox, cursorTime time.Time, cur
8787
filteredSandboxes = append(filteredSandboxes, sandbox)
8888
}
8989
}
90-
sandboxes = filteredSandboxes
9190

92-
// Sort the sandboxes to apply limit correctly
93-
SortPaginatedSandboxesDesc(sandboxes)
94-
95-
// Apply limit (get limit + 1 for pagination if possible)
96-
if len(sandboxes) > int(limit) {
97-
sandboxes = sandboxes[:limit+1]
98-
}
99-
100-
return sandboxes
91+
return filteredSandboxes
10192
}
10293

10394
// SortPaginatedSandboxesDesc sorts the sandboxes by StartedAt (descending),

0 commit comments

Comments
 (0)