Fix active alerts filter to exclude recovery notifications

Only equipment_down alerts should be counted as "active alerts that need attention".
Equipment_up alerts are informational recovery notifications and don't require action.
This commit is contained in:
Graham McIntire 2026-01-03 11:09:13 -06:00
parent f7b681e8f7
commit aff602e7dd
No known key found for this signature in database

View file

@ -33,6 +33,7 @@ defmodule Towerops.Alerts do
@doc """
Returns the list of active (unresolved) alerts for an organization.
Only returns equipment_down alerts, as equipment_up alerts are informational.
"""
def list_organization_active_alerts(organization_id) do
Repo.all(
@ -40,6 +41,7 @@ defmodule Towerops.Alerts do
join: e in assoc(a, :equipment),
join: s in assoc(e, :site),
where: s.organization_id == ^organization_id,
where: a.alert_type == :equipment_down,
where: is_nil(a.resolved_at),
order_by: [desc: a.triggered_at],
preload: [equipment: {e, site: s}, acknowledged_by: :acknowledged_by]