From cc53dd6a64b26002427d92482f98ef36723f4886 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 6 Mar 2026 13:02:21 -0600 Subject: [PATCH] fix: access interface stats through latest_stat association The template accessed if_in_octets/if_out_octets directly on the Interface struct, but these fields live on InterfaceStat. Access through interface.latest_stat with nil guard to prevent KeyError when the association is not loaded. --- lib/towerops_web/live/device_live/show.html.heex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/towerops_web/live/device_live/show.html.heex b/lib/towerops_web/live/device_live/show.html.heex index 3c453192..0aff8183 100644 --- a/lib/towerops_web/live/device_live/show.html.heex +++ b/lib/towerops_web/live/device_live/show.html.heex @@ -1393,13 +1393,13 @@ - - {if interface.if_in_octets, - do: format_bytes(interface.if_in_octets), + {if interface.latest_stat && interface.latest_stat.if_in_octets, + do: format_bytes(interface.latest_stat.if_in_octets), else: "-"} - {if interface.if_out_octets, - do: format_bytes(interface.if_out_octets), + {if interface.latest_stat && interface.latest_stat.if_out_octets, + do: format_bytes(interface.latest_stat.if_out_octets), else: "-"}