Skip to content

Commit 38436e1

Browse files
committed
Review comments
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
1 parent 6f1d961 commit 38436e1

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

coderd/database/querier.go

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

coderd/database/querier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/stretchr/testify/require"
1616

1717
"cdr.dev/slog/sloggers/slogtest"
18+
1819
"github.com/coder/coder/v2/coderd/coderdtest"
1920
"github.com/coder/coder/v2/coderd/database"
2021
"github.com/coder/coder/v2/coderd/database/db2sdk"
@@ -3474,6 +3475,5 @@ func TestOrganizationDeleteTrigger(t *testing.T) {
34743475

34753476
func requireUsersMatch(t testing.TB, expected []database.User, found []database.GetUsersRow, msg string) {
34763477
t.Helper()
3477-
foundUsers := database.ConvertUserRows(found)
3478-
require.ElementsMatch(t, expected, foundUsers, msg)
3478+
require.ElementsMatch(t, expected, database.ConvertUserRows(found), msg)
34793479
}

coderd/database/queries.sql.go

Lines changed: 1 addition & 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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ FROM workspace_prebuilds p
1515
LEFT JOIN template_version_presets tvp_curr
1616
ON tvp_curr.id = p.current_preset_id -- See https://github.com/coder/internal/issues/398.
1717
WHERE (b.transition = 'start'::workspace_transition
18-
-- Jobs that are not in terminal states.
1918
AND pj.job_status = 'succeeded'::provisioner_job_status);
2019

2120
-- name: GetTemplatePresetsWithPrebuilds :many
@@ -79,7 +78,6 @@ WHERE lb.rn <= lb.desired_instances -- Fetch the last N builds, where N is the n
7978
GROUP BY lb.template_version_id, lb.preset_id, lb.job_status;
8079

8180
-- name: ClaimPrebuild :one
82-
-- TODO: rewrite to use named CTE instead?
8381
UPDATE workspaces w
8482
SET owner_id = @new_user_id::uuid,
8583
name = @new_name::text,
@@ -95,7 +93,7 @@ WHERE w.id IN (SELECT p.id
9593
AND b.template_version_preset_id = @preset_id::uuid
9694
AND p.lifecycle_state = 'ready'::workspace_agent_lifecycle_state
9795
ORDER BY random()
98-
LIMIT 1 FOR UPDATE OF p SKIP LOCKED)
96+
LIMIT 1 FOR UPDATE OF p SKIP LOCKED) -- Ensure that a concurrent request will not select the same prebuild.
9997
RETURNING w.id, w.name;
10098

10199
-- name: InsertPresetPrebuild :one

0 commit comments

Comments
 (0)