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
+15
View File
@@ -5553,6 +5553,17 @@ WHERE
name ILIKE '%' || $7 || '%'
ELSE true
END
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
-- @authorize_filter
ORDER BY
last_used_at DESC
LIMIT
CASE
WHEN $9 :: integer > 0 THEN
$9
END
OFFSET
$8
`
type GetWorkspacesParams struct {
@@ -5563,6 +5574,8 @@ type GetWorkspacesParams struct {
TemplateName string `db:"template_name" json:"template_name"`
TemplateIds []uuid.UUID `db:"template_ids" json:"template_ids"`
Name string `db:"name" json:"name"`
Offset int32 `db:"offset_" json:"offset_"`
Limit int32 `db:"limit_" json:"limit_"`
}
func (q *sqlQuerier) GetWorkspaces(ctx context.Context, arg GetWorkspacesParams) ([]Workspace, error) {
@@ -5574,6 +5587,8 @@ func (q *sqlQuerier) GetWorkspaces(ctx context.Context, arg GetWorkspacesParams)
arg.TemplateName,
pq.Array(arg.TemplateIds),
arg.Name,
arg.Offset,
arg.Limit,
)
if err != nil {
return nil, err