mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: workspace filter query supported in backend (#2232)
* feat: add support for template in workspace filter * feat: Implement workspace search filter to support names * Use new query param parser for pagination fields * Remove excessive calls, use filters on a single query Co-authored-by: Garrett <garrett@coder.com>
This commit is contained in:
@@ -8,13 +8,33 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetTemplatesByIDs :many
|
||||
-- name: GetTemplatesWithFilter :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
templates
|
||||
WHERE
|
||||
id = ANY(@ids :: uuid [ ]);
|
||||
-- Optionally include deleted templates
|
||||
templates.deleted = @deleted
|
||||
-- Filter by organization_id
|
||||
AND CASE
|
||||
WHEN @organization_id :: uuid != '00000000-00000000-00000000-00000000' THEN
|
||||
organization_id = @organization_id
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by exact name
|
||||
AND CASE
|
||||
WHEN @exact_name :: text != '' THEN
|
||||
LOWER("name") = LOWER(@exact_name)
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by ids
|
||||
AND CASE
|
||||
WHEN array_length(@ids :: uuid[], 1) > 0 THEN
|
||||
id = ANY(@ids)
|
||||
ELSE true
|
||||
END
|
||||
;
|
||||
|
||||
-- name: GetTemplateByOrganizationAndName :one
|
||||
SELECT
|
||||
@@ -28,15 +48,6 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetTemplatesByOrganization :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
templates
|
||||
WHERE
|
||||
organization_id = $1
|
||||
AND deleted = $2;
|
||||
|
||||
-- name: InsertTemplate :one
|
||||
INSERT INTO
|
||||
templates (
|
||||
|
||||
Reference in New Issue
Block a user