feat: Workspaces filtering (#1972)

Co-authored-by: G r e y <grey@coder.com>
Co-authored-by: Kira Pilot <kira@coder.com>
This commit is contained in:
Garrett Delfosse
2022-06-03 12:20:28 -05:00
committed by GitHub
parent ac6cb269db
commit 8b03e2b0e1
14 changed files with 377 additions and 121 deletions

View File

@ -3509,16 +3509,28 @@ WHERE
owner_id = $3
ELSE true
END
-- Filter by name
AND CASE
WHEN $4 :: text != '' THEN
LOWER(name) = LOWER($4)
ELSE true
END
`
type GetWorkspacesWithFilterParams struct {
Deleted bool `db:"deleted" json:"deleted"`
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
OwnerID uuid.UUID `db:"owner_id" json:"owner_id"`
Name string `db:"name" json:"name"`
}
func (q *sqlQuerier) GetWorkspacesWithFilter(ctx context.Context, arg GetWorkspacesWithFilterParams) ([]Workspace, error) {
rows, err := q.db.QueryContext(ctx, getWorkspacesWithFilter, arg.Deleted, arg.OrganizationID, arg.OwnerID)
rows, err := q.db.QueryContext(ctx, getWorkspacesWithFilter,
arg.Deleted,
arg.OrganizationID,
arg.OwnerID,
arg.Name,
)
if err != nil {
return nil, err
}