Skip to content

Commit 7906899

Browse files
committed
chore: get latest preset id
1 parent 0f21e44 commit 7906899

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

coderd/database/queries.sql.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/prebuilds.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ WITH latest_prebuilds AS (
6565
AND workspaces.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID
6666
AND NOT workspaces.deleted
6767
),
68+
workspace_latest_presets AS (
69+
SELECT DISTINCT ON (latest_prebuilds.id) latest_prebuilds.id AS workspace_id,
70+
workspace_builds.template_version_preset_id AS current_preset_id
71+
FROM latest_prebuilds
72+
JOIN workspace_builds ON workspace_builds.workspace_id = latest_prebuilds.id
73+
WHERE workspace_builds.transition = 'start'::workspace_transition
74+
ORDER BY latest_prebuilds.id, workspace_builds.build_number DESC
75+
),
6876
ready_agents AS (
6977
SELECT
7078
latest_prebuilds.job_id,
@@ -81,12 +89,12 @@ SELECT
8189
latest_prebuilds.name,
8290
latest_prebuilds.template_id,
8391
latest_prebuilds.template_version_id,
84-
-- TODO(cian): this can be null, which differs from prebuilt_workspaces view.
8592
latest_prebuilds.template_version_preset_id AS current_preset_id,
8693
COALESCE(ready_agents.ready, false)::boolean AS ready,
8794
latest_prebuilds.created_at
8895
FROM latest_prebuilds
8996
LEFT JOIN ready_agents ON ready_agents.job_id = latest_prebuilds.job_id
97+
LEFT JOIN workspace_latest_presets ON workspace_latest_presets.workspace_id = latest_prebuilds.id
9098
;
9199

92100
-- name: CountInProgressPrebuilds :many

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy