Skip to content

Commit

Permalink
use pgformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Forfold committed Jun 30, 2023
1 parent afc4203 commit 28aa199
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions alert/queries.sql
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;

0 comments on commit 28aa199

Please sign in to comment.