diff --git a/lib/towerops/maintenance.ex b/lib/towerops/maintenance.ex index 6bc58b3a..f1424e4a 100644 --- a/lib/towerops/maintenance.ex +++ b/lib/towerops/maintenance.ex @@ -101,12 +101,10 @@ defmodule Towerops.Maintenance do end defp active_windows_base(query, organization_id, now) do - from(w in query, - where: - w.organization_id == ^organization_id and - w.starts_at <= ^now and w.ends_at >= ^now and - w.suppress_alerts == true - ) + query + |> MaintenanceWindowQuery.for_organization(organization_id) + |> MaintenanceWindowQuery.active(now) + |> where([w], w.suppress_alerts == true) end defp scope_to_device(query, device_id, nil) do