mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd/database): add ListTasks query (#20282)
Relates to https://github.com/coder/internal/issues/981 Adds a `ListTasks` query that allows filtering by OwnerID and OrganizationID.
This commit is contained in:
@@ -21,3 +21,10 @@ SELECT * FROM tasks_with_status WHERE id = @id::uuid;
|
||||
|
||||
-- name: GetTaskByWorkspaceID :one
|
||||
SELECT * FROM tasks_with_status WHERE workspace_id = @workspace_id::uuid;
|
||||
|
||||
-- name: ListTasks :many
|
||||
SELECT * FROM tasks_with_status tws
|
||||
WHERE tws.deleted_at IS NULL
|
||||
AND CASE WHEN @owner_id::UUID != '00000000-0000-0000-0000-000000000000' THEN tws.owner_id = @owner_id::UUID ELSE TRUE END
|
||||
AND CASE WHEN @organization_id::UUID != '00000000-0000-0000-0000-000000000000' THEN tws.organization_id = @organization_id::UUID ELSE TRUE END
|
||||
ORDER BY tws.created_at DESC;
|
||||
|
||||
Reference in New Issue
Block a user