<commit_before>defmodule EspiDni.BotSupervisor do
  use Supervisor
  alias EspiDni.Repo
  alias EspiDni.Team
  alias EspiDni.SlackRtm

  # A simple module attribute that stores the supervisor name
  @name EspiDni.BotSupervisor

  def start_link do
    Supervisor.start_link(__MODULE__, :ok, name: @name)
  end

  def start_bot(token) do
    Supervisor.start_child(@name, worker(SlackRtm, [token]))
  end

  def init(:ok) do
    children = for team <- Repo.all(Team), do: worker(SlackRtm, [team.slack_token], restart: :temporary)
    supervise(children, strategy: :one_for_one)
  end
end<commit_msg>Pass unique id to worker for each bot connection<commit_after>defmodule EspiDni.BotSupervisor do
  use Supervisor
  alias EspiDni.Repo
  alias EspiDni.Team
  alias EspiDni.SlackRtm

  # A simple module attribute that stores the supervisor name
  @name EspiDni.BotSupervisor

  def start_link do
    Supervisor.start_link(__MODULE__, :ok, name: @name)
  end

  def start_bot(token) do
    Supervisor.start_child(@name, worker(SlackRtm, [token]))
  end

  def init(:ok) do
    children = for team <- Repo.all(Team) do
      worker(SlackRtm, [team.slack_token], restart: :temporary, id: worker_id(team))
    end
    supervise(children, strategy: :one_for_one)
  end

  defp worker_id(team) do
    "#{__MODULE__}-#{team.id}"
  end
end
{'fraction_non_alphanumeric': 0.09337349397590361, 'fraction_numerical': 0.0, 'mean_word_length': 4.151162790697675, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2110708', 'n_tokens_mistral': 477, 'n_tokens_neox': 467, 'n_words': 123}