8000 refactor: clarify comment for SQL query · coder/coder@5150a5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5150a5c

Browse files
refactor: clarify comment for SQL query
1 parent 2312f41 commit 5150a5c

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

coderd/database/querier.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 6 additions & 5 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: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ FROM workspace_latest_builds wlb
5050
WHERE wlb.job_status IN ('pending'::provisioner_job_status, 'running'::provisioner_job_status)
5151
GROUP BY t.id, wpb.template_version_id, wpb.transition;
5252

53-
-- GetPresetsBackoff groups workspace builds by template version ID.
53+
-- GetPresetsBackoff groups workspace builds by preset ID.
54+
-- Each preset is associated with exactly one template version ID.
5455
-- For each group, the query checks up to N of the most recent jobs that occurred within the
5556
-- lookback period, where N equals the number of desired instances for the corresponding preset.
56-
-- If at least one of the job within a group has failed, we should backoff on the corresponding template version ID.
57-
-- Query returns a list of template version IDs for which we should backoff.
57+
-- If at least one of the job within a group has failed, we should backoff on the corresponding preset ID.
58+
-- Query returns a list of preset IDs for which we should backoff.
5859
-- Only active template versions with configured presets are considered.
5960
-- We also return the number of failed workspace builds that occurred during the lookback period.
6061
--
@@ -75,13 +76,13 @@ WITH filtered_builds AS (
7576
AND wlb.transition = 'start'::workspace_transition
7677
),
7778
time_sorted_builds AS (
78-
-- Group builds by template version, then sort each group by created_at.
79+
-- Group builds by preset, then sort each group by created_at.
7980
SELECT fb.template_version_id, fb.created_at, fb.preset_id, fb.job_status, fb.desired_instances,
8081
ROW_NUMBER() OVER (PARTITION BY fb.preset_id ORDER BY fb.created_at DESC) as rn
8182
FROM filtered_builds fb
8283
),
8384
failed_count AS (
84-
-- Count failed builds per template version/preset in the given period
85+
-- Count failed builds per preset in the given period
8586
SELECT preset_id, COUNT(*) AS num_failed
8687
FROM filtered_builds
8788
WHERE job_status = 'failed'::provisioner_job_status

0 commit comments

Comments
 (0)
0