mirror of
https://github.com/correl/planning-poker.git
synced 2024-11-25 11:09:55 +00:00
32 lines
857 B
Elixir
32 lines
857 B
Elixir
defmodule PlanningpokerWeb.Presence do
|
|
@moduledoc """
|
|
Provides presence tracking to channels and processes.
|
|
|
|
See the [`Phoenix.Presence`](http://hexdocs.pm/phoenix/Phoenix.Presence.html)
|
|
docs for more details.
|
|
"""
|
|
use Phoenix.Presence, otp_app: :planningpoker,
|
|
pubsub_server: Planningpoker.PubSub
|
|
require Logger
|
|
alias Planningpoker.Db
|
|
|
|
def fetch("room:" <> room, entries) do
|
|
users =
|
|
entries
|
|
|> Map.keys()
|
|
|> Db.get_users()
|
|
|> Enum.into(%{})
|
|
votes =
|
|
users
|
|
|> Map.keys()
|
|
|> Db.get_votes(room)
|
|
|> Enum.into(%{}, fn {{u, _r}, v} -> {u, v} end)
|
|
|
|
for {key, %{metas: metas}} <- entries, into: %{} do
|
|
{key, %{metas: metas,
|
|
name: users[key],
|
|
vote: Map.get(votes, key)}}
|
|
end
|
|
end
|
|
def fetch(_topic, entries), do: entries
|
|
end
|