- Add jump_credo_checks ~> 0.4 with all 20 checks enabled - Fix all standard Credo issues: 139 @spec (113 done, 26 remain), 4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom, 2 max line length, 9 assert_receive timeout - Fix 170+ jump_credo_checks warnings: - 117 TopLevelAliasImportRequire: move nested alias/import to module top - 32 UseObanProWorker: switch to Oban.Pro.Worker - 4 DoctestIExExamples: add doctests / create test file - ~20 WeakAssertion: strengthen type-check assertions - Various ConditionalAssertion, AssertReceiveTimeout fixes - Exclude vendor/ from Credo analysis - Remaining: 175 warnings (mostly opinionated WeakAssertion, AvoidSocketAssignsInTest), 26 @spec annotations
31 lines
778 B
Elixir
31 lines
778 B
Elixir
defmodule MicrowavepropWeb.Api.V1.BeaconJSON do
|
|
@moduledoc "Renders beacon representations."
|
|
|
|
alias Microwaveprop.Beacons.Beacon
|
|
|
|
@spec index(map()) :: map()
|
|
def index(%{beacons: beacons}), do: %{data: Enum.map(beacons, &data/1)}
|
|
|
|
@spec show(map()) :: map()
|
|
def show(%{beacon: beacon}), do: %{data: data(beacon)}
|
|
|
|
defp data(%Beacon{} = b) do
|
|
%{
|
|
id: b.id,
|
|
callsign: b.callsign,
|
|
frequency_mhz: b.frequency_mhz,
|
|
lat: b.lat,
|
|
lon: b.lon,
|
|
grid: b.grid,
|
|
power_mw: b.power_mw,
|
|
height_ft: b.height_ft,
|
|
on_the_air: b.on_the_air,
|
|
approved: b.approved,
|
|
keying: b.keying,
|
|
bearing: b.bearing,
|
|
beamwidth_deg: b.beamwidth_deg,
|
|
notes: b.notes,
|
|
inserted_at: b.inserted_at
|
|
}
|
|
end
|
|
end
|