perform returns a map instead of a list

parent b2e02569
...@@ -9,10 +9,13 @@ defmodule Grengine.Conductor do ...@@ -9,10 +9,13 @@ defmodule Grengine.Conductor do
def perform do def perform do
get_performances() get_performances()
|> Enum.map( fn perf -> |> Enum.reduce(%{}, fn perf, acc ->
do_performance(perf) {name, val} = do_performance(perf)
case name do
nil -> acc
_ -> Map.put(acc, name, val)
end
end) end)
|> Enum.reject( fn val -> is_nil(val) end)
end end
...@@ -27,8 +30,8 @@ defmodule Grengine.Conductor do ...@@ -27,8 +30,8 @@ defmodule Grengine.Conductor do
[{_n, _l, {:performance, name}}, _pid, :undefined] = perf [{_n, _l, {:performance, name}}, _pid, :undefined] = perf
values = Performance.get_values(name) values = Performance.get_values(name)
case length( Map.keys(values)) do case length( Map.keys(values)) do
0 -> nil 0 -> {nil, nil}
_ -> %{name => Performance.get_values(name)} _ -> {name, Performance.get_values(name)}
end end
end end
......
...@@ -24,8 +24,8 @@ defmodule ConductorTest do ...@@ -24,8 +24,8 @@ defmodule ConductorTest do
test "handle single performance" do test "handle single performance" do
values = Conductor.perform() values = Conductor.perform()
assert is_list(values) assert is_map(values)
assert length(values) == 1 assert length(Map.keys(values)) == 1
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment