From 5436a300989e593ddd7e68f6d9a4e0a063797ea9 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 23 Mar 2026 10:38:41 -0500 Subject: [PATCH] fix/traffic-graph-monitored-nil (#127) Reviewed-on: https://git.mcintire.me/graham/towerops-web/pulls/127 --- lib/towerops_web/live/device_live/show.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index eca1abae..9c42a5bb 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -233,6 +233,13 @@ defmodule ToweropsWeb.DeviceLive.Show do end end + @impl true + def handle_info({:alert_changed, _organization_id}, socket) do + # Alert changed in this organization - we don't show alerts on device page + # so just ignore this message + {:noreply, socket} + end + @impl true def handle_info({FormComponent, {:check_created, _check}}, socket) do {:noreply, @@ -1204,10 +1211,10 @@ defmodule ToweropsWeb.DeviceLive.Show do # Calculate BPS per interface first, then aggregate by timestamp # This avoids issues with misaligned timestamps between interfaces - # Only processes monitored interfaces to match actual traffic being tracked + # Only processes monitored interfaces (nil treated as true for backwards compatibility) defp aggregate_interface_traffic_stats(interfaces, since) do interfaces - |> Enum.filter(& &1.monitored) + |> Enum.filter(&(&1.monitored != false)) |> Enum.flat_map(fn interface -> interface.id |> Snmp.get_interface_stats(since: since, limit: 1000) @@ -1407,9 +1414,10 @@ defmodule ToweropsWeb.DeviceLive.Show do # Sums capacity of active interfaces at each timestamp defp calculate_interface_capacity_data(all_stats, device) do # Build a map of interface_id -> {rx_capacity, tx_capacity} for quick lookup + # Only include monitored interfaces (nil treated as true for backwards compatibility) interface_capacity_map = device.interfaces - |> Enum.filter(& &1.monitored) + |> Enum.filter(&(&1.monitored != false)) |> Map.new(fn interface -> cap = interface.configured_capacity_bps || interface.if_speed || 0 {interface.id, {cap, cap}}