From 59c1dd4d2e514948d43bb21a86dfd6c98e643262 Mon Sep 17 00:00:00 2001 From: Robert J Samson Date: Fri, 24 Jun 2016 10:26:55 -0400 Subject: [PATCH] Fix Elixir 1.3 warnings --- lib/venue.ex | 23 ++++++++++++++++------- test/support/channel_case.ex | 6 ++++++ web/channels/execution_socket.ex | 4 ++-- web/channels/ticker_socket.ex | 6 +++--- web/plugs/api/authenticate.ex | 1 - 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/venue.ex b/lib/venue.ex index a6eda1b..b839b24 100644 --- a/lib/venue.ex +++ b/lib/venue.ex @@ -75,15 +75,24 @@ defmodule Stackfooter.Venue do def handle_call({:order_status, order_id, account}, from, {num_orders, _, venue, _, closed_orders, open_orders, _stock_quotes} = state) do spawn(fn -> + order = - open_orders - |> Enum.find(fn order -> order.id == order_id end) + case (open_orders |> Enum.find(fn order -> order.id == order_id end)) do + nil -> + (closed_orders |> Enum.find(fn order -> order.id == order_id end)) + ord -> + ord + end - if order == nil do - order = - closed_orders - |> Enum.find(fn order -> order.id == order_id end) - end + # order = + # open_orders + # |> Enum.find(fn order -> order.id == order_id end) + # + # if order == nil do + # order = + # closed_orders + # |> Enum.find(fn order -> order.id == order_id end) + # end cond do order_id >= num_orders || order_id < 0 -> diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 87b11b5..22c2f6e 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -36,6 +36,12 @@ defmodule Stackfooter.ChannelCase do # Ecto.Adapters.SQL.restart_test_transaction(Stackfooter.Repo, []) # end + :ok = Ecto.Adapters.SQL.Sandbox.checkout(Stackfooter.Repo) + + unless tags[:async] do + Ecto.Adapters.SQL.Sandbox.mode(Stackfooter.Repo, {:shared, self()}) + end + :ok end end diff --git a/web/channels/execution_socket.ex b/web/channels/execution_socket.ex index 6d58faf..ee79a0b 100644 --- a/web/channels/execution_socket.ex +++ b/web/channels/execution_socket.ex @@ -29,7 +29,7 @@ defmodule Stackfooter.ExecutionSocket do {:ok, req, state} end - def websocket_info({:execution, execution} = info, req, state) do + def websocket_info({:execution, execution} = _info, req, state) do resp = case Poison.encode(execution) do {:ok, encoded} -> encoded @@ -40,7 +40,7 @@ defmodule Stackfooter.ExecutionSocket do {:reply, {:text, resp}, req, state} end - def websocket_info(info, req, state) do + def websocket_info(_info, req, state) do {:ok, req, state} end diff --git a/web/channels/ticker_socket.ex b/web/channels/ticker_socket.ex index 4fa0c80..27badc7 100644 --- a/web/channels/ticker_socket.ex +++ b/web/channels/ticker_socket.ex @@ -16,11 +16,11 @@ defmodule Stackfooter.TickerSocket do end) case params do - %{"trading_account" => account, "venue" => venue, "stock" => stock} -> + %{"trading_account" => _account, "venue" => venue, "stock" => stock} -> # Uncomment for documented behavior instead of observed behavior # PubSub.subscribe Stackfooter.PubSub, self, "tickers:#{account}-#{venue}-#{stock}" PubSub.subscribe Stackfooter.PubSub, self, "tickers:#{venue}-#{stock}" - %{"trading_account" => account, "venue" => venue} -> + %{"trading_account" => _account, "venue" => venue} -> # Uncomment for documented behavior instead of observed behavior # PubSub.subscribe Stackfooter.PubSub, self, "tickers:#{account}-#{venue}" PubSub.subscribe Stackfooter.PubSub, self, "tickers:#{venue}" @@ -34,7 +34,7 @@ defmodule Stackfooter.TickerSocket do {:ok, req, state} end - def websocket_info({:ticker, ticker} = info, req, state) do + def websocket_info({:ticker, ticker} = _info, req, state) do resp = case Poison.encode(ticker) do {:ok, encoded} -> encoded diff --git a/web/plugs/api/authenticate.ex b/web/plugs/api/authenticate.ex index a094b74..8b1405c 100644 --- a/web/plugs/api/authenticate.ex +++ b/web/plugs/api/authenticate.ex @@ -1,7 +1,6 @@ defmodule Stackfooter.Plugs.Api.Authenticate do use Stackfooter.Web, :controller alias Stackfooter.ApiKeyRegistry - alias Stackfooter.Repo def init(options) do options