Meet SourceLevel, an All-in-one Data & Analytics for Engineering Teams

SourceLevel provides metrics and insights by collecting data from many sources such as GitHub and GitLab. Our product brings visibility over every corner of the delivery pipeline in a Data & Analytics Solution for Engineering Teams.

Get started for free
Go to line 1
defmodule HexpmWeb.API.UserView do
Go to line 2
  use HexpmWeb, :view
Go to line 4
  def render("index." <> _, %{users: users}) do
Go to line 5
    render_many(users, __MODULE__, "show")
Go to line 8
  def render("show." <> _, %{user: user}) do
Go to line 9
    render_one(user, __MODULE__, "show")
Go to line 12
  def render("me." <> _, %{user: user}) do
Go to line 13
    render_one(user, __MODULE__, "me")
Go to line 16
  def render("minimal." <> _, %{user: user}) do
Go to line 17
    render_one(user, __MODULE__, "minimal")
Go to line 20
  def render("audit_logs." <> _, %{audit_logs: audit_logs}) do
Go to line 21
    render_many(audit_logs, HexpmWeb.API.AuditLogView, "show")
Go to line 24
  def render("show", %{user: user}) do
Go to line 26
      username: user.username,
Go to line 27
      full_name: user.full_name,
Go to line 28
      handles: handles(user),
Go to line 29
      url: Routes.api_user_url(Endpoint, :show, user),
Go to line 30
      inserted_at: user.inserted_at,
Go to line 31
      updated_at: user.updated_at
Go to line 33
    |> put_maybe(:email, User.email(user, :public))
Go to line 34
    |> ViewHelpers.include_if_loaded(:owned_packages, user.owned_packages, &owned_packages/1)
Go to line 35
    |> ViewHelpers.include_if_loaded(:packages, user.owned_packages, &packages/1)
Go to line 38
  def render("me", %{user: user}) do
Go to line 39
    render_one(user, __MODULE__, "show")
Go to line 40
    |> Map.put(:organizations, organizations(user))
Go to line 43
  def render("minimal", %{user: user}) do
Go to line 45
      username: user.username,
Go to line 46
      url: Routes.api_user_url(Endpoint, :show, user)
Go to line 48
    |> put_maybe(:email, User.email(user, :public))
Go to line 51
  def handles(user) do
Go to line 52
    Enum.into(UserHandles.render(user), %{}, fn {field, _service, url} ->
Go to line 53
      {field, url}
Go to line 57
  # TODO: deprecated
Go to line 58
  defp owned_packages(packages) do
Go to line 59
    Enum.into(packages, %{}, fn package ->
Go to line 60
      {package.name, ViewHelpers.url_for_package(package)}
Go to line 64
  defp packages(packages) do
Go to line 66
    |> Enum.sort_by(&[repository_sort(&1), &1.name])
Go to line 67
    |> Enum.map(fn package ->
Go to line 69
        name: package.name,
Go to line 70
        repository: repository_name(package),
Go to line 71
        url: ViewHelpers.url_for_package(package),
Go to line 72
        html_url: ViewHelpers.html_url_for_package(package)
Go to line 77
  defp repository_name(%Package{repository_id: 1}), do: "hexpm"
Go to line 78
  defp repository_name(%Package{repository: %Repository{name: name}}), do: name
Go to line 80
  # TODO: DRY up
Go to line 81
  # Atoms sort before strings
Go to line 82
  defp repository_sort(%Package{repository_id: 1}), do: :first
Go to line 83
  defp repository_sort(%Package{repository: %Repository{name: name}}), do: name
Go to line 85
  defp organizations(user) do
Go to line 86
    Enum.map(user.organization_users, fn ru ->
Go to line 88
        name: ru.organization.name,
Go to line 89
        role: ru.role
Go to line 94
  defp put_maybe(map, _key, nil), do: map
Go to line 95
  defp put_maybe(map, key, value), do: Map.put(map, key, value)