Skip to content

fix(coderd/database): fix limit in GetUserWorkspaceBuildParameters #11954

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 2 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(coderd/database): fix limit in GetUserWorkspaceBuildParameters
  • Loading branch information
mafredri committed Jan 31, 2024
commit e8d82f0127bb1bad5fcbd09765d7cb6f8ba07c78
45 changes: 24 additions & 21 deletions coderd/database/queries/workspacebuildparameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ WHERE
workspace_build_id = $1;

-- name: GetUserWorkspaceBuildParameters :many
-- name: GetUserWorkspaceBuildParameters :many
SELECT DISTINCT ON (tvp.name)
tvp.name,
wbp.value
FROM
workspace_build_parameters wbp
JOIN
workspace_builds wb ON wb.id = wbp.workspace_build_id
JOIN
workspaces w ON w.id = wb.workspace_id
JOIN
template_version_parameters tvp ON tvp.template_version_id = wb.template_version_id
WHERE
w.owner_id = $1
AND wb.transition = 'start'
AND w.template_id = $2
AND tvp.ephemeral = false
AND tvp.name = wbp.name
ORDER BY
tvp.name, wb.created_at DESC
SELECT name, value
FROM (
SELECT DISTINCT ON (tvp.name)
tvp.name,
wbp.value,
wb.created_at
FROM
workspace_build_parameters wbp
JOIN
workspace_builds wb ON wb.id = wbp.workspace_build_id
JOIN
workspaces w ON w.id = wb.workspace_id
JOIN
template_version_parameters tvp ON tvp.template_version_id = wb.template_version_id
WHERE
w.owner_id = $1
AND wb.transition = 'start'
AND w.template_id = $2
AND tvp.ephemeral = false
AND tvp.name = wbp.name
ORDER BY
tvp.name, wb.created_at DESC
) q1
ORDER BY created_at DESC, name
LIMIT 100;