Skip to content

Commit f6b5d54

Browse files
committed
clean up subquery
1 parent 8b0c6a7 commit f6b5d54

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

coderd/database/queries.sql.go

Lines changed: 5 additions & 6 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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ WITH
5353
latest_prebuilds
5454
AS (
5555
SELECT
56-
workspaces.name,
57-
workspaces.template_id,
58-
latest_build.id,
5956
latest_build.workspace_id,
57+
workspaces.name,
58+
workspaces.template_id,
6059
latest_build.template_version_id,
61-
latest_build.job_id,
6260
latest_build.template_version_preset_id,
61+
latest_build.job_id,
6362
latest_build.created_at
6463
FROM
6564
workspaces
@@ -101,7 +100,7 @@ WITH
101100
AS (
102101
SELECT
103102
latest_prebuilds.workspace_id AS workspace_id,
104-
BOOL_AND(workspace_agents.lifecycle_state = 'ready'::workspace_agent_lifecycle_state)::boolean AS ready
103+
COALESCE(BOOL_AND(workspace_agents.lifecycle_state = 'ready'::workspace_agent_lifecycle_state), false)::boolean AS ready
105104
FROM
106105
latest_prebuilds
107106
LEFT JOIN workspace_resources ON
@@ -117,7 +116,7 @@ SELECT
117116
latest_prebuilds.template_id,
118117
latest_prebuilds.template_version_id,
119118
latest_prebuilds.template_version_preset_id AS current_preset_id,
120-
COALESCE(agent_readiness.ready, false) AS ready,
119+
agent_readiness.ready,
121120
latest_prebuilds.created_at
122121
FROM
123122
latest_prebuilds

0 commit comments

Comments
 (0)