Skip to content

Commit 6b4d6dc

Browse files
committed
chore: get latest preset id
1 parent c95b6d0 commit 6b4d6dc

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

coderd/database/queries.sql.go

Lines changed: 12 additions & 3 deletions
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ WITH latest_prebuilds AS (
5555
workspaces.name,
5656
workspaces.template_id,
5757
workspace_latest_builds.template_version_id,
58-
workspace_latest_builds.template_version_preset_id,
5958
workspace_latest_builds.job_id,
6059
workspaces.created_at
6160
FROM workspace_latest_builds
@@ -65,6 +64,16 @@ WITH latest_prebuilds AS (
6564
AND workspaces.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID
6665
AND NOT workspaces.deleted
6766
),
67+
workspace_latest_presets AS (
68+
SELECT DISTINCT ON (latest_prebuilds.id)
69+
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+
AND workspace_builds.template_version_preset_id IS NOT NULL
75+
ORDER BY latest_prebuilds.id, workspace_builds.build_number DESC
76+
),
6877
ready_agents AS (
6978
SELECT
7079
latest_prebuilds.job_id,
@@ -81,12 +90,12 @@ SELECT
8190
latest_prebuilds.name,
8291
latest_prebuilds.template_id,
8392
latest_prebuilds.template_version_id,
84-
-- TODO(cian): this can be null, which differs from prebuilt_workspaces view.
85-
latest_prebuilds.template_version_preset_id AS current_preset_id,
93+
workspace_latest_presets.current_preset_id,
8694
COALESCE(ready_agents.ready, false)::boolean AS ready,
8795
latest_prebuilds.created_at
8896
FROM latest_prebuilds
8997
LEFT JOIN ready_agents ON ready_agents.job_id = latest_prebuilds.job_id
98+
LEFT JOIN workspace_latest_presets ON workspace_latest_presets.workspace_id = latest_prebuilds.id
9099
;
91100

92101
-- 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