diff --git a/lib/towerops/alerts.ex b/lib/towerops/alerts.ex index 0525947e..7665ec8d 100644 --- a/lib/towerops/alerts.ex +++ b/lib/towerops/alerts.ex @@ -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) diff --git a/lib/towerops/llm/network_insight_prompt.ex b/lib/towerops/llm/network_insight_prompt.ex index 4f3d3736..3b390e11 100644 --- a/lib/towerops/llm/network_insight_prompt.ex +++ b/lib/towerops/llm/network_insight_prompt.ex @@ -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) diff --git a/lib/towerops/llm/network_snapshot.ex b/lib/towerops/llm/network_snapshot.ex index 329d3a0e..5bc8ed5f 100644 --- a/lib/towerops/llm/network_snapshot.ex +++ b/lib/towerops/llm/network_snapshot.ex @@ -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, diff --git a/lib/towerops/monitoring.ex b/lib/towerops/monitoring.ex index c9282f34..1a00b698 100644 --- a/lib/towerops/monitoring.ex +++ b/lib/towerops/monitoring.ex @@ -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 diff --git a/lib/towerops/workers/cloud_latency_probe_worker.ex b/lib/towerops/workers/cloud_latency_probe_worker.ex index bbc37532..7cc7f32d 100644 --- a/lib/towerops/workers/cloud_latency_probe_worker.ex +++ b/lib/towerops/workers/cloud_latency_probe_worker.ex @@ -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 diff --git a/lib/towerops/workers/mikrotik_webhook_worker.ex b/lib/towerops/workers/mikrotik_webhook_worker.ex index 0e2b391f..f3abd68b 100644 --- a/lib/towerops/workers/mikrotik_webhook_worker.ex +++ b/lib/towerops/workers/mikrotik_webhook_worker.ex @@ -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 diff --git a/lib/towerops_web/live/insights_live/index.ex b/lib/towerops_web/live/insights_live/index.ex index a6f25f0e..046dd5e2 100644 --- a/lib/towerops_web/live/insights_live/index.ex +++ b/lib/towerops_web/live/insights_live/index.ex @@ -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))}