fix: update alert_type atom comparisons to strings in AlertLive

Changed all alert_type == :device_down to alert_type == "device_down"
in AlertLive.Index to match the string-based alert_type schema.
This commit is contained in:
Graham McIntire 2026-03-05 09:49:47 -06:00
parent c8237cbcdc
commit 117d13b44b
No known key found for this signature in database

View file

@ -197,7 +197,7 @@ defmodule ToweropsWeb.AlertLive.Index do
# Compute counts for filter tabs
counts = %{
all: length(all_alerts),
critical: Enum.count(all_alerts, &(&1.alert_type == :device_down and is_nil(&1.resolved_at))),
critical: Enum.count(all_alerts, &(&1.alert_type == "device_down" and is_nil(&1.resolved_at))),
unresolved: Enum.count(all_alerts, &is_nil(&1.resolved_at)),
resolved: Enum.count(all_alerts, &(not is_nil(&1.resolved_at)))
}
@ -212,7 +212,7 @@ defmodule ToweropsWeb.AlertLive.Index do
defp filter_alerts(alerts, "all"), do: alerts
defp filter_alerts(alerts, "critical"),
do: Enum.filter(alerts, &(&1.alert_type == :device_down and is_nil(&1.resolved_at)))
do: Enum.filter(alerts, &(&1.alert_type == "device_down" and is_nil(&1.resolved_at)))
defp filter_alerts(alerts, "unresolved"), do: Enum.filter(alerts, &is_nil(&1.resolved_at))
@ -236,8 +236,8 @@ defmodule ToweropsWeb.AlertLive.Index do
Enum.sort_by(alerts, fn alert ->
severity_weight =
cond do
alert.alert_type == :device_down and is_nil(alert.resolved_at) -> 0
alert.alert_type == :device_down -> 1
alert.alert_type == "device_down" and is_nil(alert.resolved_at) -> 0
alert.alert_type == "device_down" -> 1
true -> 2
end
@ -256,7 +256,7 @@ defmodule ToweropsWeb.AlertLive.Index do
end)
|> Enum.map(fn {{site_id, site_name}, site_alerts} ->
sub_info = if site_id, do: site_subscribers[site_id]
critical_count = Enum.count(site_alerts, &(&1.alert_type == :device_down and is_nil(&1.resolved_at)))
critical_count = Enum.count(site_alerts, &(&1.alert_type == "device_down" and is_nil(&1.resolved_at)))
%{
site_id: site_id,
@ -302,7 +302,7 @@ defmodule ToweropsWeb.AlertLive.Index do
alert.resolved_at ->
"gray"
alert.alert_type == :device_down and is_nil(alert.resolved_at) ->
alert.alert_type == "device_down" and is_nil(alert.resolved_at) ->
age_minutes = DateTime.diff(DateTime.utc_now(), alert.triggered_at, :minute)
cond do