Skip to content

Commit

Permalink
Use list accumulator and Map.new in get/2 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjos committed Jul 25, 2024
1 parent 95b5eeb commit 824cc41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/absinthe/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ defmodule Absinthe.Subscription do
name
|> Registry.lookup(key)
|> MapSet.new(fn {_pid, doc_id} -> doc_id end)
|> Enum.reduce(%{}, fn doc_id, acc ->
|> Enum.reduce([], fn doc_id, acc ->
case Registry.lookup(name, doc_id) do
[] ->
acc

[{_pid, doc} | _rest] ->
Map.put_new_lazy(acc, doc_id, fn ->
Map.update!(doc, :initial_phases, &PipelineSerializer.unpack/1)
end)
doc = Map.update!(doc, :initial_phases, &PipelineSerializer.unpack/1)
[{doc_id, doc} | acc]
end
end)
|> Map.new()
end

@doc false
Expand Down

0 comments on commit 824cc41

Please sign in to comment.