28 lines
711 B
Elixir
28 lines
711 B
Elixir
defmodule NullaWeb.Generic.NodeinfoController do
|
|
use NullaWeb, :controller
|
|
alias Nulla.Accounts
|
|
alias NullaWeb.Generic.NodeinfoJSON
|
|
|
|
def index(conn, _params) do
|
|
url = NullaWeb.Endpoint.url()
|
|
|
|
json(conn, NodeinfoJSON.index(url))
|
|
end
|
|
|
|
def show(conn, _params) do
|
|
version = Application.spec(:nulla, :vsn) |> to_string()
|
|
total = Accounts.get_total_users_count()
|
|
month = Accounts.get_active_users_count(30)
|
|
halfyear = Accounts.get_active_users_count(180)
|
|
|
|
users = %{
|
|
total: total,
|
|
month: month,
|
|
halfyear: halfyear
|
|
}
|
|
|
|
instance = Application.get_env(:nulla, :instance) |> Map.new()
|
|
|
|
json(conn, NodeinfoJSON.show(version, users, instance))
|
|
end
|
|
end
|