Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daveminer committed Nov 17, 2023
1 parent 3b6c3ad commit 5443bfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions lib/basket_web/live/overview.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ defmodule BasketWeb.Overview do
{:ok, response} ->
%{"bars" => ticker_bars} = response

initial_bars =
if ticker_bars == %{} do
%{"t" => "Market Closed"}
else
Enum.reduce(ticker_bars, %{}, fn {k, v}, acc ->
Map.put(acc, k, %TickerBar{value: v})
end)
end
initial_bars = build_ticker_bars(ticker_bars)

assign(
socket,
Expand Down Expand Up @@ -124,6 +117,16 @@ defmodule BasketWeb.Overview do
"""
end

defp build_ticker_bars(ticker_bars) do
if ticker_bars == %{} do
%{"t" => "Market Closed"}
else
Enum.reduce(ticker_bars, %{}, fn {k, v}, acc ->
Map.put(acc, k, %TickerBar{value: v})
end)
end
end

defp load_tickers do
case Http.Alpaca.list_assets() do
{:ok, result} ->
Expand Down
4 changes: 2 additions & 2 deletions test/basket_web/live/overview_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ defmodule BasketWeb.OverviewTest do
value: "2023-11-15T20:59:00Z",
prev_value: "2023-11-15T20:58:00Z"
},
"v" => %TickerBar{value: 43031, prev_value: 43025},
"v" => %TickerBar{value: 43_031, prev_value: 43_025},
"vw" => %TickerBar{value: 188.117416, prev_value: 187.137416}
}
]
Expand All @@ -284,7 +284,7 @@ defmodule BasketWeb.OverviewTest do
value: "2023-11-15T20:59:00Z",
prev_value: "2023-11-15T20:59:00Z"
},
"v" => %TickerBar{value: 43031, prev_value: 43031},
"v" => %TickerBar{value: 43_031, prev_value: 43_031},
"vw" => %TickerBar{
value: 188.117416,
prev_value: 187.117416
Expand Down

0 comments on commit 5443bfb

Please sign in to comment.