fix: resolve all dialyzer type warnings across codebase

- Narrow @spec for NetworkInsightPrompt.build/1 and NetworkSnapshot.build/1
- Match/discard unmatched returns in monitoring.ex, alerts.ex, and
  cloud_latency_probe_worker.ex
- Remove unreachable :rate_limited pattern in mikrotik_webhook_worker.ex
  (resolve_error returns {:rate_limited, pos_integer()}, never bare atom)
- Fix gettext pluralisation in insights_live/index.ex: dngettext was
  receiving a string where it expected a non_neg_integer count
This commit is contained in:
Graham McIntire 2026-06-08 16:17:10 -05:00
parent b5e3c1f977
commit 080e5111e4
7 changed files with 40 additions and 24 deletions

View file

@ -397,7 +397,7 @@ defmodule Towerops.Alerts do
)
Enum.each(alerts, fn alert ->
AlertNotificationWorker.enqueue_acknowledge(alert.id)
_ = AlertNotificationWorker.enqueue_acknowledge(alert.id)
Subscriptions.publish_alert_event(alert, "acknowledged")
end)

View file

@ -62,7 +62,7 @@ defmodule Towerops.LLM.NetworkInsightPrompt do
@max_observations 5
@spec build(map()) :: [map()]
@spec build(map()) :: [%{role: String.t(), content: String.t()}]
def build(snapshot) when is_map(snapshot) do
payload = Jason.encode!(snapshot, pretty: true)

View file

@ -57,7 +57,18 @@ defmodule Towerops.LLM.NetworkSnapshot do
@top_n 10
@stale_poll_hours 24
@spec build(String.t()) :: map()
@spec build(String.t()) :: %{
:agents => map(),
:backhaul => map(),
:existing_insights => term(),
:gaiia => map(),
:organization_id => String.t(),
:organization_name => term(),
:preseem => map(),
:snmp => map(),
:totals => map(),
:wireless => map()
}
def build(organization_id) when is_binary(organization_id) do
%{
organization_id: organization_id,

View file

@ -478,6 +478,7 @@ defmodule Towerops.Monitoring do
:ok
ids ->
_ =
Oban.cancel_all_jobs(
from(j in Oban.Job,
where: j.queue == "check_executors",

View file

@ -38,7 +38,9 @@ defmodule Towerops.Workers.CloudLatencyProbeWorker do
device_chunks = Enum.chunk_every(devices, @chunk_size)
_ =
for poller <- cloud_pollers do
_ =
for chunk <- device_chunks do
Phoenix.PubSub.broadcast(
Towerops.PubSub,

View file

@ -59,8 +59,7 @@ defmodule Towerops.Workers.MikrotikWebhookWorker do
# Gaiia outages will resolve on retry and we'll re-record the
# event (events table dedupes nothing today, that's intentional —
# the audit log is allowed to have duplicates from retries).
:rate_limited -> {:error, :rate_limited}
{:rate_limited, _} -> {:error, :rate_limited}
{:rate_limited, _retry_after} -> {:error, :rate_limited}
_ -> :ok
end
end

View file

@ -114,12 +114,15 @@ defmodule ToweropsWeb.InsightsLive.Index do
{:info, t("Insight regeneration queued. New insights will appear shortly.")}
else
{:error,
"%{ok} worker queued, %{fail} worker failed to queue. Check logs."
|> ngettext(
Gettext.dngettext(
ToweropsWeb.Gettext,
"default",
"%{ok} worker queued, %{fail} worker failed to queue. Check logs.",
"%{ok} workers queued, %{fail} workers failed to queue. Check logs.",
ok_count
)
|> then(&Gettext.dngettext(ToweropsWeb.Gettext, "", &1, &1, ok_count: ok_count, fail: fail_count))}
max(ok_count, 0),
ok_count: ok_count,
fail: fail_count
)}
end
{:noreply, put_flash(socket, elem(flash, 0), elem(flash, 1))}