philomena/lib/philomena_web/plugs/channel_plug.ex

19 lines
357 B
Elixir
Raw Permalink Normal View History

2019-11-30 07:30:45 +01:00
defmodule PhilomenaWeb.ChannelPlug do
alias Plug.Conn
alias Philomena.Channels.Channel
alias Philomena.Repo
import Ecto.Query
def init([]), do: []
def call(conn, _opts) do
live_channels =
Channel
|> where(is_live: true)
|> Repo.aggregate(:count, :id)
conn
|> Conn.assign(:live_channels, live_channels)
end
2020-01-11 05:20:19 +01:00
end