<commit_before>defmodule Api.UserView do
  use Api.Web, :view

  alias Api.{TeamView, InviteView, UserHelper}

  def render("index.json", %{users: users}) do
    %{data: render_many(users, __MODULE__, "user_short.json")}
  end

  def render("show.json", %{user: user}) do
    %{data: render_one(user, __MODULE__, "user.json")}
  end

  def render("user.json", %{user: user}) do
    %{
      id: user.id,
      first_name: user.first_name,
      last_name: user.last_name,
      gravatar_hash: UserHelper.gravatar_hash(user),
      display_name: UserHelper.display_name(user),
      birthday: user.birthday,
      bio: user.bio,
      github_handle: user.github_handle,
      twitter_handle: user.twitter_handle,
      linkedin_url: user.linkedin_url,
      employment_status: user.employment_status,
      college: user.college,
      company: user.company,
      team: if user.team do render_one(user.team, TeamView, "team_with_role.json") end
    }
  end

  def render("user_short.json", %{user: user}) do
    %{
      id: user.id,
      first_name: user.first_name,
      last_name: user.last_name,
      gravatar_hash: UserHelper.gravatar_hash(user),
      display_name: UserHelper.display_name(user)
    }
  end

  def render("me.json", %{user: user}) do
    %{
      data: %{
        id: user.id,
        email: user.email,
        first_name: user.first_name,
        last_name: user.last_name,
        gravatar_hash: UserHelper.gravatar_hash(user),
        display_name: UserHelper.display_name(user),
        birthday: user.birthday,
        bio: user.bio,
        github_handle: user.github_handle,
        twitter_handle: user.twitter_handle,
        linkedin_url: user.linkedin_url,
        employment_status: user.employment_status,
        college: user.college,
        company: user.company,
        team: if user.team do render_one(user.team, TeamView, "team_with_role.json") end,
        invitations: if user.invitations do render_many(user.invitations, InviteView, "invite.json") end,
      }
    }
  end
end<commit_msg>Add role to /me endpoint response<commit_after>defmodule Api.UserView do
  use Api.Web, :view

  alias Api.{TeamView, InviteView, UserHelper}

  def render("index.json", %{users: users}) do
    %{data: render_many(users, __MODULE__, "user_short.json")}
  end

  def render("show.json", %{user: user}) do
    %{data: render_one(user, __MODULE__, "user.json")}
  end

  def render("user.json", %{user: user}) do
    %{
      id: user.id,
      first_name: user.first_name,
      last_name: user.last_name,
      gravatar_hash: UserHelper.gravatar_hash(user),
      display_name: UserHelper.display_name(user),
      birthday: user.birthday,
      bio: user.bio,
      github_handle: user.github_handle,
      twitter_handle: user.twitter_handle,
      linkedin_url: user.linkedin_url,
      employment_status: user.employment_status,
      college: user.college,
      company: user.company,
      team: if user.team do render_one(user.team, TeamView, "team_with_role.json") end
    }
  end

  def render("user_short.json", %{user: user}) do
    %{
      id: user.id,
      first_name: user.first_name,
      last_name: user.last_name,
      gravatar_hash: UserHelper.gravatar_hash(user),
      display_name: UserHelper.display_name(user)
    }
  end

  def render("me.json", %{user: user}) do
    %{
      data: %{
        id: user.id,
        email: user.email,
        first_name: user.first_name,
        last_name: user.last_name,
        role: user.role,
        gravatar_hash: UserHelper.gravatar_hash(user),
        display_name: UserHelper.display_name(user),
        birthday: user.birthday,
        bio: user.bio,
        github_handle: user.github_handle,
        twitter_handle: user.twitter_handle,
        linkedin_url: user.linkedin_url,
        employment_status: user.employment_status,
        college: user.college,
        company: user.company,
        team: if user.team do render_one(user.team, TeamView, "team_with_role.json") end,
        invitations: if user.invitations do render_many(user.invitations, InviteView, "invite.json") end,
      }
    }
  end
end
{'fraction_non_alphanumeric': 0.11544991511035653, 'fraction_numerical': 0.0, 'mean_word_length': 2.957773512476008, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1841090', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1364, 'n_words': 282}