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 ->
|
Enum.each(alerts, fn alert ->
|
||||||
AlertNotificationWorker.enqueue_acknowledge(alert.id)
|
_ = AlertNotificationWorker.enqueue_acknowledge(alert.id)
|
||||||
Subscriptions.publish_alert_event(alert, "acknowledged")
|
Subscriptions.publish_alert_event(alert, "acknowledged")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ defmodule Towerops.LLM.NetworkInsightPrompt do
|
||||||
|
|
||||||
@max_observations 5
|
@max_observations 5
|
||||||
|
|
||||||
@spec build(map()) :: [map()]
|
@spec build(map()) :: [%{role: String.t(), content: String.t()}]
|
||||||
def build(snapshot) when is_map(snapshot) do
|
def build(snapshot) when is_map(snapshot) do
|
||||||
payload = Jason.encode!(snapshot, pretty: true)
|
payload = Jason.encode!(snapshot, pretty: true)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,18 @@ defmodule Towerops.LLM.NetworkSnapshot do
|
||||||
@top_n 10
|
@top_n 10
|
||||||
@stale_poll_hours 24
|
@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
|
def build(organization_id) when is_binary(organization_id) do
|
||||||
%{
|
%{
|
||||||
organization_id: organization_id,
|
organization_id: organization_id,
|
||||||
|
|
|
||||||
|
|
@ -478,13 +478,14 @@ defmodule Towerops.Monitoring do
|
||||||
:ok
|
:ok
|
||||||
|
|
||||||
ids ->
|
ids ->
|
||||||
Oban.cancel_all_jobs(
|
_ =
|
||||||
from(j in Oban.Job,
|
Oban.cancel_all_jobs(
|
||||||
where: j.queue == "check_executors",
|
from(j in Oban.Job,
|
||||||
where: j.state in ["available", "scheduled", "retryable"],
|
where: j.queue == "check_executors",
|
||||||
where: fragment("?->>'check_id' = ANY(?)", j.args, ^ids)
|
where: j.state in ["available", "scheduled", "retryable"],
|
||||||
|
where: fragment("?->>'check_id' = ANY(?)", j.args, ^ids)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,17 @@ defmodule Towerops.Workers.CloudLatencyProbeWorker do
|
||||||
|
|
||||||
device_chunks = Enum.chunk_every(devices, @chunk_size)
|
device_chunks = Enum.chunk_every(devices, @chunk_size)
|
||||||
|
|
||||||
for poller <- cloud_pollers do
|
_ =
|
||||||
for chunk <- device_chunks do
|
for poller <- cloud_pollers do
|
||||||
Phoenix.PubSub.broadcast(
|
_ =
|
||||||
Towerops.PubSub,
|
for chunk <- device_chunks do
|
||||||
"agent:#{poller.id}:latency_probe",
|
Phoenix.PubSub.broadcast(
|
||||||
{:latency_probe_jobs, chunk}
|
Towerops.PubSub,
|
||||||
)
|
"agent:#{poller.id}:latency_probe",
|
||||||
|
{:latency_probe_jobs, chunk}
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,7 @@ defmodule Towerops.Workers.MikrotikWebhookWorker do
|
||||||
# Gaiia outages will resolve on retry and we'll re-record the
|
# Gaiia outages will resolve on retry and we'll re-record the
|
||||||
# event (events table dedupes nothing today, that's intentional —
|
# event (events table dedupes nothing today, that's intentional —
|
||||||
# the audit log is allowed to have duplicates from retries).
|
# the audit log is allowed to have duplicates from retries).
|
||||||
:rate_limited -> {:error, :rate_limited}
|
{:rate_limited, _retry_after} -> {:error, :rate_limited}
|
||||||
{:rate_limited, _} -> {:error, :rate_limited}
|
|
||||||
_ -> :ok
|
_ -> :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -114,12 +114,15 @@ defmodule ToweropsWeb.InsightsLive.Index do
|
||||||
{:info, t("Insight regeneration queued. New insights will appear shortly.")}
|
{:info, t("Insight regeneration queued. New insights will appear shortly.")}
|
||||||
else
|
else
|
||||||
{:error,
|
{:error,
|
||||||
"%{ok} worker queued, %{fail} worker failed to queue. Check logs."
|
Gettext.dngettext(
|
||||||
|> ngettext(
|
ToweropsWeb.Gettext,
|
||||||
|
"default",
|
||||||
|
"%{ok} worker queued, %{fail} worker failed to queue. Check logs.",
|
||||||
"%{ok} workers queued, %{fail} workers failed to queue. Check logs.",
|
"%{ok} workers queued, %{fail} workers failed to queue. Check logs.",
|
||||||
ok_count
|
max(ok_count, 0),
|
||||||
)
|
ok_count: ok_count,
|
||||||
|> then(&Gettext.dngettext(ToweropsWeb.Gettext, "", &1, &1, ok_count: ok_count, fail: fail_count))}
|
fail: fail_count
|
||||||
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
{:noreply, put_flash(socket, elem(flash, 0), elem(flash, 1))}
|
{:noreply, put_flash(socket, elem(flash, 0), elem(flash, 1))}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue