These query modules existed on disk but were never tracked; the previous refactor commit started using them but didn't add the files.
36 lines
958 B
Elixir
36 lines
958 B
Elixir
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
|