diff --git a/lib/towerops/organizations.ex b/lib/towerops/organizations.ex index 471ca2af..8b20b6f0 100644 --- a/lib/towerops/organizations.ex +++ b/lib/towerops/organizations.ex @@ -564,7 +564,7 @@ defmodule Towerops.Organizations do join: u in assoc(m, :user), where: m.organization_id == ^organization.id, where: m.role == :owner, - order_by: [asc: m.inserted_at], + order_by: [desc: m.is_default, asc: m.inserted_at, asc: m.id], limit: 1, select: u ) diff --git a/lib/towerops_web/live/alert_live/index.ex b/lib/towerops_web/live/alert_live/index.ex index 96dac9d9..3df8c9e5 100644 --- a/lib/towerops_web/live/alert_live/index.ex +++ b/lib/towerops_web/live/alert_live/index.ex @@ -186,6 +186,11 @@ defmodule ToweropsWeb.AlertLive.Index do {:noreply, load_alerts(socket, socket.assigns.current_scope.organization.id)} end + @impl true + def handle_info({:alert_changed, _org_id}, socket) do + {:noreply, load_alerts(socket, socket.assigns.current_scope.organization.id)} + end + defp load_alerts(socket, organization_id) do all_alerts = Alerts.list_organization_alerts(organization_id, %{"limit" => 500}) diff --git a/lib/towerops_web/live/dashboard_live.ex b/lib/towerops_web/live/dashboard_live.ex index da200b8e..dd6f5738 100644 --- a/lib/towerops_web/live/dashboard_live.ex +++ b/lib/towerops_web/live/dashboard_live.ex @@ -96,6 +96,11 @@ defmodule ToweropsWeb.DashboardLive do {:noreply, load_dashboard_data(socket, socket.assigns.current_scope.organization.id)} end + @impl true + def handle_info({:alert_changed, _org_id}, socket) do + {:noreply, load_dashboard_data(socket, socket.assigns.current_scope.organization.id)} + end + defp load_dashboard_data(socket, organization_id) do organization = socket.assigns.current_scope.organization summary = Dashboard.get_dashboard_summary(organization_id)