From 25397139c15670b237650f0545f2d30afa48cc3f Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 30 Jan 2026 13:01:44 -0600 Subject: [PATCH] nif ci fix complie in ci --- lib/towerops/snmp/agent_discovery.ex | 8 +------- lib/towerops/snmp/discovery.ex | 2 +- lib/towerops/workers/discovery_worker.ex | 2 -- lib/towerops_web/channels/agent_channel.ex | 11 ++++++----- .../controllers/api/v1/devices_controller.ex | 7 ++++--- lib/towerops_web/live/device_live/show.ex | 9 +++++---- lib/towerops_web/live/graph_live/show.ex | 7 ++++--- lib/towerops_web/plugs/update_session_activity.ex | 7 ++++--- mix.exs | 2 +- 9 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/towerops/snmp/agent_discovery.ex b/lib/towerops/snmp/agent_discovery.ex index 4ea6a77e..1c8613cc 100644 --- a/lib/towerops/snmp/agent_discovery.ex +++ b/lib/towerops/snmp/agent_discovery.ex @@ -26,7 +26,6 @@ defmodule Towerops.Snmp.AgentDiscovery do {:ok, %Device{}} """ - alias Ecto.Association.NotLoaded alias Towerops.Devices alias Towerops.Devices.Device, as: DeviceSchema alias Towerops.Snmp.Adapters.Replay @@ -112,11 +111,7 @@ defmodule Towerops.Snmp.AgentDiscovery do end defp count_interfaces(discovered_device) do - case discovered_device.interfaces do - %NotLoaded{} -> 0 - list when is_list(list) -> length(list) - _ -> 0 - end + length(discovered_device.interfaces) end # Build connection opts for Replay adapter @@ -141,7 +136,6 @@ defmodule Towerops.Snmp.AgentDiscovery do @spec count_sensors(DiscoveredDevice.t()) :: non_neg_integer() defp count_sensors(discovered_device) do case discovered_device.sensors do - %NotLoaded{} -> 0 list when is_list(list) -> length(list) _ -> 0 end diff --git a/lib/towerops/snmp/discovery.ex b/lib/towerops/snmp/discovery.ex index 3aa3192e..8f347722 100644 --- a/lib/towerops/snmp/discovery.ex +++ b/lib/towerops/snmp/discovery.ex @@ -349,7 +349,7 @@ defmodule Towerops.Snmp.Discovery do results = Enum.reduce(device_list, %{enqueued: 0, failed: 0, errors: []}, fn device, acc -> case DiscoveryWorker.enqueue(device.id) do - {:ok, _job} -> + :ok -> %{acc | enqueued: acc.enqueued + 1} {:error, reason} -> diff --git a/lib/towerops/workers/discovery_worker.ex b/lib/towerops/workers/discovery_worker.ex index 086eabf5..fd0f0b48 100644 --- a/lib/towerops/workers/discovery_worker.ex +++ b/lib/towerops/workers/discovery_worker.ex @@ -182,8 +182,6 @@ defmodule Towerops.Workers.DiscoveryWorker do error end - - result end # Private helpers diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index 878fd339..7438eda6 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -462,11 +462,12 @@ defmodule ToweropsWeb.AgentChannel do ) # Broadcast for real-time UI updates - Phoenix.PubSub.broadcast( - Towerops.PubSub, - "device:#{device.id}", - {:discovery_completed, device.id} - ) + _ = + Phoenix.PubSub.broadcast( + Towerops.PubSub, + "device:#{device.id}", + {:discovery_completed, device.id} + ) :ok diff --git a/lib/towerops_web/controllers/api/v1/devices_controller.ex b/lib/towerops_web/controllers/api/v1/devices_controller.ex index 3590864c..c6619bd7 100644 --- a/lib/towerops_web/controllers/api/v1/devices_controller.ex +++ b/lib/towerops_web/controllers/api/v1/devices_controller.ex @@ -88,9 +88,10 @@ defmodule ToweropsWeb.Api.V1.DevicesController do case Devices.create_device(device_params, opts) do {:ok, device} -> # Trigger SNMP discovery if enabled - if device.snmp_enabled do - DiscoveryWorker.enqueue(device.id) - end + _ = + if device.snmp_enabled do + DiscoveryWorker.enqueue(device.id) + end conn |> put_status(:created) diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index a54f5894..5f4fe796 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -158,10 +158,11 @@ defmodule ToweropsWeb.DeviceLive.Show do # Private functions defp maybe_subscribe_and_schedule_refresh(socket, device_id) do - if connected?(socket) do - _ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") - _ = Process.send_after(self(), :refresh_data, 10_000) - end + _ = + if connected?(socket) do + _ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") + Process.send_after(self(), :refresh_data, 10_000) + end :ok end diff --git a/lib/towerops_web/live/graph_live/show.ex b/lib/towerops_web/live/graph_live/show.ex index a7b8b9ac..cbe82a07 100644 --- a/lib/towerops_web/live/graph_live/show.ex +++ b/lib/towerops_web/live/graph_live/show.ex @@ -57,9 +57,10 @@ defmodule ToweropsWeb.GraphLive.Show do end defp maybe_subscribe_to_device(socket, device_id) do - if connected?(socket) do - _ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") - end + _ = + if connected?(socket) do + Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") + end :ok end diff --git a/lib/towerops_web/plugs/update_session_activity.ex b/lib/towerops_web/plugs/update_session_activity.ex index bc4deabb..9bdab2b4 100644 --- a/lib/towerops_web/plugs/update_session_activity.ex +++ b/lib/towerops_web/plugs/update_session_activity.ex @@ -26,9 +26,10 @@ defmodule ToweropsWeb.Plugs.UpdateSessionActivity do def call(conn, _opts) do token = get_session(conn, :user_token) - if token do - _ = Task.start(fn -> update_session_activity(token) end) - end + _ = + if token do + Task.start(fn -> update_session_activity(token) end) + end conn end diff --git a/mix.exs b/mix.exs index c9ee30c9..2c84be3f 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ defmodule Towerops.MixProject do start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), - compilers: [:phoenix_live_view] ++ Mix.compilers(), + compilers: [:towerops_nif, :phoenix_live_view] ++ Mix.compilers(), listeners: [Phoenix.CodeReloader], dialyzer: dialyzer() ]