Skip to content

chore: allow search by build params in workspace search filter #12694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 22, 2024
Next Next commit
chore: workspace search filter allow search by params
  • Loading branch information
Emyrk committed Mar 21, 2024
commit 6cedb78e64d4d97c5738e0225fdd6efe95fbca56
1 change: 1 addition & 0 deletions coderd/database/modelqueries.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
arg.Deleted,
arg.Status,
arg.OwnerID,
pq.Array(arg.HasParam),
arg.OwnerUsername,
arg.TemplateName,
pq.Array(arg.TemplateIDs),
Expand Down
66 changes: 41 additions & 25 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions coderd/database/queries/workspaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ ON
workspaces.owner_id = users.id
LEFT JOIN LATERAL (
SELECT
workspace_builds.id,
workspace_builds.transition,
workspace_builds.template_version_id,
template_versions.name AS template_version_name,
Expand Down Expand Up @@ -184,6 +185,19 @@ WHERE
workspaces.owner_id = @owner_id
ELSE true
END
-- Filter by build parameter
AND CASE WHEN array_length(@has_param :: uuid[], 1) > 0 THEN
EXISTS (
SELECT
1
FROM
workspace_build_parameters
WHERE
workspace_build_parameters.workspace_build_id = latest_build.id AND
workspace_build_parameters.name = ANY(@has_param)
)
ELSE true
END
-- Filter by owner_name
AND CASE
WHEN @owner_username :: text != '' THEN
Expand Down