2023-12-04 14:39:27 +00:00
|
|
|
defmodule BoardWiseWeb.CoachJSON do
|
|
|
|
alias BoardWise.Coaches.Coach
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Renders a list of coaches.
|
|
|
|
"""
|
|
|
|
def index(%{coaches: coaches}) do
|
|
|
|
%{data: for(coach <- coaches, do: data(coach))}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp data(%Coach{} = coach) do
|
|
|
|
%{
|
|
|
|
site: coach.site,
|
|
|
|
username: coach.username,
|
2023-12-04 20:35:01 +00:00
|
|
|
name: coach.name,
|
|
|
|
image_url: coach.image_url,
|
2023-12-05 22:02:58 +00:00
|
|
|
languages: coach.languages,
|
2023-12-04 14:39:27 +00:00
|
|
|
rapid: coach.rapid,
|
|
|
|
blitz: coach.blitz,
|
|
|
|
bullet: coach.bullet
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|