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-07 02:59:29 +00:00
|
|
|
title: coach.title,
|
2023-12-05 22:32:30 +00:00
|
|
|
languages: coach.languages,
|
2023-12-04 14:39:27 +00:00
|
|
|
rapid: coach.rapid,
|
|
|
|
blitz: coach.blitz,
|
|
|
|
bullet: coach.bullet
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|