feat: add pagination to getWorkspaces (#4521)

This commit is contained in:
Garrett Delfosse
2022-10-13 12:41:13 -04:00
committed by GitHub
parent 574e5d37c7
commit 459ee4e66a
8 changed files with 114 additions and 13 deletions
@@ -695,6 +695,19 @@ func (q *fakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
workspaces = append(workspaces, workspace)
}
if arg.Offset > 0 {
if int(arg.Offset) > len(workspaces) {
return []database.Workspace{}, nil
}
workspaces = workspaces[arg.Offset:]
}
if arg.Limit > 0 {
if int(arg.Limit) > len(workspaces) {
return workspaces, nil
}
workspaces = workspaces[:arg.Limit]
}
return workspaces, nil
}