<commit_before>defmodule Poxa.Adapter.GProc do
  @behaviour Poxa.Registry
  @moduledoc """
  """

  import :gproc

  def register(channel) do
    reg({:p, :l, {:pusher, channel}})
  end

  def register(channel, {user_id, user_info}) do
    reg({:p, :l, {:pusher, channel}}, {user_id, user_info})
  end

  def unregister(channel) do
    unreg({:p, :l, {:pusher, channel}});
  end

  def send_event(channel, {caller, message}) do
    :gproc.send({:p, :l, {:pusher, channel}}, {caller, message})
  end

  def send_event(channel, {caller, message, socket_id}) do
    :gproc.send({:p, :l, {:pusher, channel}}, {caller, message, socket_id})
  end

  def users(channel) do
    find_users(channel)
    |> Enum.map(fn {user_id, _} -> user_id end)
  end

  def user_count(channel) do
    find_users(channel)
    |> Enum.count
  end

  def occupied?(channel) do
    match = {{:p, :l, {:pusher, channel}}, :_, :_}
    select_count([{match, [], [true]}]) != 0
  end

  def subscription_count(channel) do
    match = {{:p, :l, {:pusher, channel}}, :_, :_}
    select_count([{match, [], [true]}])
  end

  def subscribed?(channel, pid) do
    match = {{:p, :l, {:pusher, channel}}, pid, :_}
    select_count([{match, [], [true]}]) != 0<commit_msg>some smarter method reuse<commit_after>defmodule Poxa.Adapter.GProc do
  @behaviour Poxa.Registry
  @moduledoc """
  """

  import :gproc

  def register(channel) do
    reg({:p, :l, {:pusher, channel}})
  end

  def register(channel, {user_id, user_info}) do
    reg({:p, :l, {:pusher, channel}}, {user_id, user_info})
  end

  def unregister(channel) do
    unreg({:p, :l, {:pusher, channel}});
  end

  def send_event(channel, {caller, message}) do
    :gproc.send({:p, :l, {:pusher, channel}}, {caller, message})
  end

  def send_event(channel, {caller, message, socket_id}) do
    :gproc.send({:p, :l, {:pusher, channel}}, {caller, message, socket_id})
  end

  def users(channel) do
    find_users(channel)
    |> Enum.map(fn {user_id, _} -> user_id end)
  end

  def user_count(channel) do
    find_users(channel)
    |> Enum.count
  end

  def occupied?(channel) do
    subscription_count(channel) != 0
  end

  def subscription_count(channel) do
    match = {{:p, :l, {:pusher, channel}}, :_, :_}
    select_count([{match, [], [true]}])
  end

  def subscribed?(channel, pid) do
    match = {{:p, :l, {:pusher, channel}}, pid, :_}
    select_count([{match, [], [true]}]) != 0
{'fraction_non_alphanumeric': 0.18411253620190318, 'fraction_numerical': 0.0016549441456350847, 'mean_word_length': 3.816733067729084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5186264', 'n_tokens_mistral': 945, 'n_tokens_neox': 913, 'n_words': 222}