Skip to content

Commit 6a0cdc7

Browse files
committedMar 20, 2024
chore: workspace search filter allow search by params
1 parent 3fe88c4 commit 6a0cdc7

File tree

3 files changed

+56
-25
lines changed

3 files changed

+56
-25
lines changed
 

‎coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
216216
arg.Deleted,
217217
arg.Status,
218218
arg.OwnerID,
219+
pq.Array(arg.HasParam),
219220
arg.OwnerUsername,
220221
arg.TemplateName,
221222
pq.Array(arg.TemplateIDs),

‎coderd/database/queries.sql.go

Lines changed: 41 additions & 25 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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ ON
9696
workspaces.owner_id = users.id
9797
LEFT JOIN LATERAL (
9898
SELECT
99+
workspace_builds.id,
99100
workspace_builds.transition,
100101
workspace_builds.template_version_id,
101102
template_versions.name AS template_version_name,
@@ -184,6 +185,19 @@ WHERE
184185
workspaces.owner_id = @owner_id
185186
ELSE true
186187
END
188+
-- Filter by build parameter
189+
AND CASE WHEN array_length(@has_param :: uuid[], 1) > 0 THEN
190+
EXISTS (
191+
SELECT
192+
1
193+
FROM
194+
workspace_build_parameters
195+
WHERE
196+
workspace_build_parameters.workspace_build_id = latest_build.id AND
197+
workspace_build_parameters.name = ANY(@has_param)
198+
)
199+
ELSE true
200+
END
187201
-- Filter by owner_name
188202
AND CASE
189203
WHEN @owner_username :: text != '' THEN

0 commit comments

Comments
 (0)