index.community/backend/lib/backend_web/views/search_view.ex
2019-07-23 14:08:43 +00:00

30 lines
690 B
Elixir

defmodule BackendWeb.SearchView do
use BackendWeb, :view
alias BackendWeb.SearchView
import Backend.Util
def render("index.json", %{instances: instances, next: next}) do
%{
results: render_many(instances, SearchView, "instance.json", as: :instance),
next: next
}
end
def render("instance.json", %{instance: instance}) do
threshold = get_config(:personal_instance_threshold)
description =
if instance.user_count != nil and instance.user_count < threshold do
nil
else
instance.description
end
%{
name: instance.domain,
description: description,
userCount: instance.user_count
}
end
end