Skip to content

Commit

Permalink
Add summarize_access_points
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInAbsurdism authored and fhunleth committed Dec 15, 2023
1 parent 95149a6 commit a904a91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions lib/vintage_net_wizard/web/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,11 @@ defmodule VintageNetWizard.Web.Api do

defp to_json(access_points) do
access_points
|> Enum.filter(&non_empty_ssid/1)
|> Enum.sort(fn %{signal_percent: a}, %{signal_percent: b} -> a >= b end)
|> Enum.uniq_by(fn %{ssid: ssid} -> ssid end)
|> VintageNetWiFi.summarize_access_points()
|> Enum.map(&Map.from_struct/1)
|> Jason.encode()
end

defp non_empty_ssid(%{ssid: ""}), do: false
defp non_empty_ssid(_other), do: true

defp configuration_from_params(conn, ssid) do
conn
|> get_body()
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule VintageNetWizard.MixProject do
{:phoenix_html, "~> 2.13 or ~> 3.0"},
{:jason, "~> 1.0"},
{:vintage_net, "~> 0.10.0 or ~> 0.11.0 or ~> 0.12.0 or ~> 0.13.0"},
{:vintage_net_wifi, "~> 0.10.6 or ~> 0.11.0 or ~> 0.12.0"},
{:vintage_net_wifi, "~> 0.12.0"},
{:credo, "~> 1.2", only: :test, runtime: false},
{:ex_doc, "~> 0.22", only: :docs, runtime: false},
{:dialyxir, "~> 1.4.1", only: :dev, runtime: false}
Expand Down

0 comments on commit a904a91

Please sign in to comment.