diff --git a/alert/queries.sql b/alert/queries.sql index 60750bc01a..0f0875da10 100644 --- a/alert/queries.sql +++ b/alert/queries.sql @@ -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; \ No newline at end of file +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;