chore: track SiteQuery and CheckQuery modules

These query modules existed on disk but were never tracked; the previous
refactor commit started using them but didn't add the files.
This commit is contained in:
Graham McIntire 2026-04-30 14:39:58 -05:00
parent fba0a1a54e
commit 115efc0314
2 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,36 @@
defmodule Towerops.Monitoring.CheckQuery do
@moduledoc """
Composable query fragments for `Towerops.Monitoring.Check`.
"""
import Ecto.Query
alias Towerops.Monitoring.Check
@doc "Starting point for a Check query."
def base, do: Check
@doc "Filter to a single organization."
def for_organization(query \\ base(), organization_id) do
where(query, [c], c.organization_id == ^organization_id)
end
@doc "Filter to a single device."
def for_device(query \\ base(), device_id) do
where(query, [c], c.device_id == ^device_id)
end
@doc "Filter by check_type."
def of_type(query \\ base(), check_type) do
where(query, [c], c.check_type == ^check_type)
end
@doc "Filter by enabled flag."
def with_enabled(query \\ base(), enabled) do
where(query, [c], c.enabled == ^enabled)
end
@doc "Default ordering by check name."
def order_by_name(query \\ base()) do
order_by(query, [c], asc: c.name)
end
end

View file

@ -0,0 +1,26 @@
defmodule Towerops.Sites.SiteQuery do
@moduledoc """
Composable query fragments for `Towerops.Sites.Site`.
"""
import Ecto.Query
alias Towerops.Sites.Site
@doc "Starting point for a Site query."
def base, do: Site
@doc "Filter to a single organization."
def for_organization(query \\ base(), organization_id) do
where(query, [s], s.organization_id == ^organization_id)
end
@doc "Filter to root sites (no parent)."
def roots(query \\ base()) do
where(query, [s], is_nil(s.parent_site_id))
end
@doc "Default display ordering by display_order then name."
def order_by_display(query \\ base()) do
order_by(query, [s], asc: s.display_order, asc: s.name)
end
end