mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat: notifications: report failed workspace builds (#14571)
This commit is contained in:
@ -179,3 +179,66 @@ WHERE
|
||||
wb.transition = 'start'::workspace_transition
|
||||
AND
|
||||
pj.completed_at IS NOT NULL;
|
||||
|
||||
-- name: GetWorkspaceBuildStatsByTemplates :many
|
||||
SELECT
|
||||
w.template_id,
|
||||
t.name AS template_name,
|
||||
t.display_name AS template_display_name,
|
||||
t.organization_id AS template_organization_id,
|
||||
COUNT(*) AS total_builds,
|
||||
COUNT(CASE WHEN pj.job_status = 'failed' THEN 1 END) AS failed_builds
|
||||
FROM
|
||||
workspace_build_with_user AS wb
|
||||
JOIN
|
||||
workspaces AS w ON
|
||||
wb.workspace_id = w.id
|
||||
JOIN
|
||||
provisioner_jobs AS pj ON
|
||||
wb.job_id = pj.id
|
||||
JOIN
|
||||
templates AS t ON
|
||||
w.template_id = t.id
|
||||
WHERE
|
||||
wb.created_at >= @since
|
||||
AND pj.completed_at IS NOT NULL
|
||||
GROUP BY
|
||||
w.template_id, template_name, template_display_name, template_organization_id
|
||||
ORDER BY
|
||||
template_name ASC;
|
||||
|
||||
-- name: GetFailedWorkspaceBuildsByTemplateID :many
|
||||
SELECT
|
||||
tv.name AS template_version_name,
|
||||
u.username AS workspace_owner_username,
|
||||
w.name AS workspace_name,
|
||||
wb.build_number AS workspace_build_number
|
||||
FROM
|
||||
workspace_build_with_user AS wb
|
||||
JOIN
|
||||
workspaces AS w
|
||||
ON
|
||||
wb.workspace_id = w.id
|
||||
JOIN
|
||||
users AS u
|
||||
ON
|
||||
w.owner_id = u.id
|
||||
JOIN
|
||||
provisioner_jobs AS pj
|
||||
ON
|
||||
wb.job_id = pj.id
|
||||
JOIN
|
||||
templates AS t
|
||||
ON
|
||||
w.template_id = t.id
|
||||
JOIN
|
||||
template_versions AS tv
|
||||
ON
|
||||
wb.template_version_id = tv.id
|
||||
WHERE
|
||||
w.template_id = $1
|
||||
AND wb.created_at >= @since
|
||||
AND pj.completed_at IS NOT NULL
|
||||
AND pj.job_status = 'failed'
|
||||
ORDER BY
|
||||
tv.name ASC, wb.build_number DESC;
|
||||
|
Reference in New Issue
Block a user