<commit_before>require 'rack/websocket'
class Realtime < Rack::WebSocket::Application
  def initialize(options = {})
    super
  end

  def on_close(env)
    @timer.cancel
  end

  def on_message(env, msg)
  end

  def on_error(env, error)
  end

  def on_open(env)
    last = nil

    @timer = EM::PeriodicTimer.new(1) do
      if last != last=current
        send_data last
      end
      sleep 0.5
    end
  end

private

  # The current JSON representation of Play that we send back.
  #
  # Returns a String, JSON-encoded.
  def current
    hash = {
      :now_playing => Play::Player.now_playing.to_json
    }<commit_msg>Bring in dem queue<commit_after>require 'rack/websocket'
class Realtime < Rack::WebSocket::Application
  def initialize(options = {})
    super
  end

  def on_close(env)
    @timer.cancel
  end

  def on_message(env, msg)
  end

  def on_error(env, error)
  end

  def on_open(env)
    last = nil

    @timer = EM::PeriodicTimer.new(1) do
      if last != last=current
        send_data last
      end
      sleep 0.5
    end
  end

private

  # The current JSON representation of Play that we send back.
  #
  # Returns a String, JSON-encoded.
  def current
    hash = { :now_playing => Play::Player.now_playing.to_json }
    hash.merge Play::Queue.to_json
{'fraction_non_alphanumeric': 0.09175738724727839, 'fraction_numerical': 0.004665629860031105, 'mean_word_length': 2.677142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5954757', 'n_tokens_mistral': 449, 'n_tokens_neox': 426, 'n_words': 121}