mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-22 08:58:00 +01:00
18 lines
357 B
Elixir
18 lines
357 B
Elixir
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
|
|
end
|