From 94f144806a058db0c26ccbcea49f4c11ad5e3d03 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 30 Apr 2026 14:16:30 -0500 Subject: [PATCH] refactor(maintenance): use MaintenanceWindowQuery in active_windows_base Replaces the last inline 'where: w.organization_id == ^...' clause in maintenance.ex with composable filters from the existing MaintenanceWindowQuery module. --- lib/towerops/maintenance.ex | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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