// alerts_queries.go contains SQL text for alert-run reads.
// Layer: adapters/outbound/postgres alerts feature.
package postgres

const (
	queryLatestAlertRun = `
SELECT
  event_id,
  location_id,
  location_name,
  as_of,
  latitude,
  longitude
FROM alert_runs
ORDER BY as_of DESC, event_emitted_at DESC
LIMIT 1`

	queryAlerts = `
SELECT
  alert_index,
  alert_id,
  event,
  headline,
  severity,
  urgency,
  certainty,
  status,
  message_type,
  category,
  response,
  description,
  instruction,
  sent,
  effective,
  onset,
  expires,
  area_description,
  sender_name
FROM alerts
WHERE run_event_id = $1
ORDER BY alert_index ASC`

	queryAlertReferences = `
SELECT
  alert_index,
  id,
  identifier,
  sender,
  sent
FROM alert_references
WHERE run_event_id = $1
ORDER BY alert_index ASC, reference_index ASC`
)
