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:
parent
2528e78ff9
commit
94f144806a
1 changed files with 4 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue