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.
This commit is contained in:
Graham McIntire 2026-04-30 14:16:30 -05:00
parent 2528e78ff9
commit 94f144806a

View file

@ -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