defmodule Microwaveprop.Commercial do @moduledoc false import Ecto.Query alias Microwaveprop.Commercial.Link alias Microwaveprop.Commercial.Sample alias Microwaveprop.Repo def enabled_links do Link |> where([l], l.enabled == true) |> Repo.all() end def create_link(attrs) do %Link{} |> Link.changeset(attrs) |> Repo.insert() end def create_sample(attrs) do %Sample{} |> Sample.changeset(attrs) |> Repo.insert() end def weather_stations do Link |> where([l], l.enabled == true and not is_nil(l.weather_station)) |> select([l], l.weather_station) |> distinct(true) |> Repo.all() end end