-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,50 @@ | ||
-- name: LockOneAlertService :one | ||
SELECT maintenance_expires_at notnull | ||
::bool AS is_maint_mode, | ||
SELECT | ||
maintenance_expires_at NOTNULL::bool AS is_maint_mode, | ||
alerts.status | ||
FROM services svc | ||
FROM | ||
services svc | ||
JOIN alerts ON alerts.service_id = svc.id | ||
WHERE alerts.id = $1 FOR | ||
UPDATE; | ||
WHERE | ||
alerts.id = $1 | ||
FOR UPDATE; | ||
|
||
-- name: RequestAlertEscalationByTime :one | ||
UPDATE escalation_policy_state | ||
SET force_escalation = TRUE | ||
WHERE alert_id = $1 | ||
AND ( | ||
last_escalation <= $2 | ||
::timestamptz | ||
OR last_escalation IS NULL | ||
) RETURNING TRUE; | ||
UPDATE | ||
escalation_policy_state | ||
SET | ||
force_escalation = TRUE | ||
WHERE | ||
alert_id = $1 | ||
AND (last_escalation <= $2::timestamptz | ||
OR last_escalation IS NULL) | ||
RETURNING | ||
TRUE; | ||
|
||
-- name: AlertHasEPState :one | ||
SELECT EXISTS | ||
( | ||
SELECT 1 | ||
FROM escalation_policy_state | ||
WHERE alert_id = $1 | ||
) | ||
AS has_ep_state; | ||
SELECT | ||
EXISTS ( | ||
SELECT | ||
1 | ||
FROM | ||
escalation_policy_state | ||
WHERE | ||
alert_id = $1) AS has_ep_state; | ||
|
||
-- name: AlertFeedback :one | ||
SELECT | ||
alert_id, noise_reason | ||
FROM alert_feedback | ||
WHERE alert_id = $1; | ||
alert_id, | ||
noise_reason | ||
FROM | ||
alert_feedback | ||
WHERE | ||
alert_id = $1; | ||
|
||
-- name: SetAlertFeedback :exec | ||
INSERT INTO alert_feedback | ||
(alert_id, noise_reason) | ||
VALUES | ||
($1, $2) | ||
ON CONFLICT | ||
(alert_id) DO | ||
UPDATE | ||
SET noise_reason = $2 | ||
WHERE alert_feedback.alert_id = $1; | ||
INSERT INTO alert_feedback(alert_id, noise_reason) | ||
VALUES ($1, $2) | ||
ON CONFLICT (alert_id) | ||
DO UPDATE SET | ||
noise_reason = $2 | ||
WHERE | ||
alert_feedback.alert_id = $1; |