277 @spec/@type annotations added to 58 files covering all public APIs: contexts (propagation, radio, weather, terrain, beacons, commercial), GRIB2 decoders, terrain analysis, duct detection, rain scatter, CSV/ADIF import, weather clients, and all Ecto schemas. Dialyzer passes with 0 errors.
39 lines
912 B
Elixir
39 lines
912 B
Elixir
defmodule Microwaveprop.Commercial do
|
|
@moduledoc false
|
|
|
|
import Ecto.Query
|
|
|
|
alias Microwaveprop.Commercial.Link
|
|
alias Microwaveprop.Commercial.Sample
|
|
alias Microwaveprop.Repo
|
|
|
|
@spec enabled_links() :: [Link.t()]
|
|
def enabled_links do
|
|
Link
|
|
|> where([l], l.enabled == true)
|
|
|> Repo.all()
|
|
end
|
|
|
|
@spec create_link(map()) :: {:ok, Link.t()} | {:error, Ecto.Changeset.t()}
|
|
def create_link(attrs) do
|
|
%Link{}
|
|
|> Link.changeset(attrs)
|
|
|> Repo.insert()
|
|
end
|
|
|
|
@spec create_sample(map()) :: {:ok, Sample.t()} | {:error, Ecto.Changeset.t()}
|
|
def create_sample(attrs) do
|
|
%Sample{}
|
|
|> Sample.changeset(attrs)
|
|
|> Repo.insert()
|
|
end
|
|
|
|
@spec weather_stations() :: [String.t()]
|
|
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
|