Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b0972f

Browse files
committed
feat: update workspace query to accept shared arg
1 parent 854f3c0 commit 8b0972f

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
275275
arg.UsingActive,
276276
arg.HasAITask,
277277
arg.HasExternalAgent,
278+
arg.Shared,
278279
arg.RequesterID,
279280
arg.Offset,
280281
arg.Limit,

coderd/database/queries.sql.go

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaces.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ WHERE
378378
latest_build.has_external_agent = sqlc.narg('has_external_agent') :: boolean
379379
ELSE true
380380
END
381+
-- Filter by shared status
382+
AND CASE
383+
WHEN sqlc.narg('shared') :: boolean IS NOT NULL THEN
384+
(workspaces.user_acl != '{}'::jsonb OR workspaces.group_acl != '{}'::jsonb) = sqlc.narg('shared') :: boolean
385+
ELSE true
386+
END
387+
381388
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
382389
-- @authorize_filter
383390
), filtered_workspaces_order AS (

0 commit comments

Comments
 (0)