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:
parent
b5e3c1f977
commit
080e5111e4
7 changed files with 40 additions and 24 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -478,13 +478,14 @@ defmodule Towerops.Monitoring do
|
|||
:ok
|
||||
|
||||
ids ->
|
||||
Oban.cancel_all_jobs(
|
||||
from(j in Oban.Job,
|
||||
where: j.queue == "check_executors",
|
||||
where: j.state in ["available", "scheduled", "retryable"],
|
||||
where: fragment("?->>'check_id' = ANY(?)", j.args, ^ids)
|
||||
_ =
|
||||
Oban.cancel_all_jobs(
|
||||
from(j in Oban.Job,
|
||||
where: j.queue == "check_executors",
|
||||
where: j.state in ["available", "scheduled", "retryable"],
|
||||
where: fragment("?->>'check_id' = ANY(?)", j.args, ^ids)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,15 +38,17 @@ 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,
|
||||
"agent:#{poller.id}:latency_probe",
|
||||
{:latency_probe_jobs, chunk}
|
||||
)
|
||||
_ =
|
||||
for poller <- cloud_pollers do
|
||||
_ =
|
||||
for chunk <- device_chunks do
|
||||
Phoenix.PubSub.broadcast(
|
||||
Towerops.PubSub,
|
||||
"agent:#{poller.id}:latency_probe",
|
||||
{:latency_probe_jobs, chunk}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue