<commit_before>defmodule SlackCoder.BuildSystem.CircleCI.Build do
  use HTTPoison.Base
  require Logger
  alias SlackCoder.BuildSystem.Build

  def new(build, id) do
    %Build{id: id, result: result(build["status"]), url: build["output_url"]}
  end

  defp result("success"), do: :success
  defp result("failed"), do: :failure
  defp result(_), do: :unknown

  defp process_url(url) do
    "https://circleci.com/api/v1.1/#{url}?circle-token=#{Application.get_env(:slack_coder, :circle_ci_token)}"
  end

  defp process_response_body(body) when is_binary(body) do
    decoded = Poison.decode!(body)
    build_num = decoded["build_num"]
    decoded["steps"]
    |> Enum.flat_map(&(&1["actions"]))
    |> Enum.filter(&(&1["type"] == "test"))
    |> Enum.map(&__MODULE__.new(&1, build_num))
  end

  defp process_request_headers(headers) do
    [{"Accept", "application/json"} | headers]
  end
end<commit_msg>Fixing double slash issue<commit_after>defmodule SlackCoder.BuildSystem.CircleCI.Build do
  use HTTPoison.Base
  require Logger
  alias SlackCoder.BuildSystem.Build

  def new(build, id) do
    %Build{id: id, result: result(build["status"]), url: build["output_url"]}
  end

  defp result("success"), do: :success
  defp result("failed"), do: :failure
  defp result(_), do: :unknown

  defp process_url("/" <> url), do: process_url(url)
  defp process_url(url) do
    "https://circleci.com/api/v1.1/#{url}?circle-token=#{Application.get_env(:slack_coder, :circle_ci_token)}"
  end

  defp process_response_body(body) when is_binary(body) do
    decoded = Poison.decode!(body)
    build_num = decoded["build_num"]
    decoded["steps"]
    |> Enum.flat_map(&(&1["actions"]))
    |> Enum.filter(&(&1["type"] == "test"))
    |> Enum.map(&__MODULE__.new(&1, build_num))
  end

  defp process_request_headers(headers) do
    [{"Accept", "application/json"} | headers]
  end
end
{'fraction_non_alphanumeric': 0.1635588705380927, 'fraction_numerical': 0.005327650506126798, 'mean_word_length': 4.708206686930091, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 2, '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': '2551279', 'n_tokens_mistral': 681, 'n_tokens_neox': 660, 'n_words': 131}