<commit_before>defmodule Jank do
  @moduledoc """
    Run Jank.go to start the web server + start the Phrampu nodes.
    I need to find a better way to do this.
  """
  defp ref(cluster) do
    {:global, {:cluster, cluster}} |> GenServer.whereis()
  end

  def update do
    spawn_link fn -> Phrampu.Constants.ss_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("sslab"), x) end) end

    spawn_link fn -> Phrampu.Constants.pod_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("pod"), x) end) end

    spawn_link fn -> Phrampu.Constants.borg_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("borg"), x) end) end

    spawn_link fn -> Phrampu.Constants.xinu_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("xinu"), x) end) end

    spawn_link fn -> Phrampu.Constants.moore_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("moore"), x) end) end

    spawn_link fn -> Phrampu.Constants.escher_hosts
      |> Enum.each(fn(x) -> Phrampu.Server.who(ref("escher"), x) end) end
  end

  def go do
    Phrampu.Server.Supervisor.start_link()
    Phrampu.Server.create("xinu", Phrampu.Constants.xinu_hosts)
    Phrampu.Server.create("borg", Phrampu.Constants.borg_hosts)
    Phrampu.Server.create("pod", Phrampu.Constants.pod_hosts)
    Phrampu.Server.create("moore", Phrampu.Constants.moore_hosts)
    Phrampu.Server.create("escher", Phrampu.Constants.escher_hosts)
    Phrampu.Server.create("sslab", Phrampu.Constants.ss_hosts)
    spawn_link fn -> HTTPModule.start end
    spawn_link fn -> Jank.update() end
  end
end<commit_msg>Refactored jank into multiple methods<commit_after>defmodule Jank do
  @moduledoc """
    Run Jank.go to start the web server + start the Phrampu nodes.
    I need to find a better way to do this.
  """
  defp clusterMap do
    %{
      "sslab" => Phrampu.Constants.ss_hosts,
      "pod" => Phrampu.Constants.pod_hosts,
      "borg" => Phrampu.Constants.borg_hosts,
      "xinu" => Phrampu.Constants.xinu_hosts,
      "moore" => Phrampu.Constants.moore_hosts,
      "escher" => Phrampu.Constants.escher_hosts,
    }
  end

  def update(cluster, urls) do
    spawn_link fn -> urls
      |> Enum.each(fn(x) -> Phrampu.Server.who(cluster, x) end)
    end
  end

  def update_all do
    clusterMap() |> Enum.each(fn({cluster, urls}) ->
      update(cluster, urls)
    end)
  end

  def create(cluster, urls) do
    Phrampu.Server.create(cluster, urls)
  end

  def create_all do
    clusterMap() |> Enum.each(fn({cluster, urls}) ->
      create(cluster, urls)
    end)
  end

  def go do
    Phrampu.Server.Supervisor.start_link()
    create_all()
    spawn_link fn -> HTTPModule.start end
    spawn_link fn -> Jank.update_all() end
  end
end
{'fraction_non_alphanumeric': 0.13444444444444445, 'fraction_numerical': 0.0, 'mean_word_length': 3.207165109034268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, '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': '5068388', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1020, 'n_words': 210}