<commit_before>class ChatController < ApplicationController
  before_filter :authenticate_user!
  CHAT_VERSION = 12

  def index
    hide_cover_image
    @chat_version = CHAT_VERSION
  end
  
  # Update the current user's last seen time in Redis, and return a list of
  # online users.
  def ping
    $redis.zadd("chat_last_seen", Time.now.to_i, current_user.id)
    
    @online_users = Rails.cache.fetch(:chat_online_users, :expires_in => 4.seconds) do
      user_ids = $redis.zrangebyscore("chat_last_seen", Time.now.to_i - 30, Time.now.to_i + 5)
      User.where(id: user_ids).map {|x| {name: x.name, url: user_url(x)} }
    end

    render :json => {online_users: @online_users, chat_version: CHAT_VERSION}
  end

  # Helper method. Takes raw message -> outputs HTML.
  def format_message(message)
    formatted = Rinku.auto_link(ERB::Util.html_escape(message), :all, 'target="_blank"')
    
    # Link @usernames.
    formatted = formatted.gsub(/@[-_A-Za-z0-9]+/) do |x|
      u = User.find_by_name(x[1..-1])<commit_msg>Update chat version.<commit_after>class ChatController < ApplicationController
  before_filter :authenticate_user!
  CHAT_VERSION = 13

  def index
    hide_cover_image
    @chat_version = CHAT_VERSION
  end
  
  # Update the current user's last seen time in Redis, and return a list of
  # online users.
  def ping
    $redis.zadd("chat_last_seen", Time.now.to_i, current_user.id)
    
    @online_users = Rails.cache.fetch(:chat_online_users, :expires_in => 4.seconds) do
      user_ids = $redis.zrangebyscore("chat_last_seen", Time.now.to_i - 30, Time.now.to_i + 5)
      User.where(id: user_ids).map {|x| {name: x.name, url: user_url(x)} }
    end

    render :json => {online_users: @online_users, chat_version: CHAT_VERSION}
  end

  # Helper method. Takes raw message -> outputs HTML.
  def format_message(message)
    formatted = Rinku.auto_link(ERB::Util.html_escape(message), :all, 'target="_blank"')
    
    # Link @usernames.
    formatted = formatted.gsub(/@[-_A-Za-z0-9]+/) do |x|
      u = User.find_by_name(x[1..-1])
{'fraction_non_alphanumeric': 0.1267605633802817, 'fraction_numerical': 0.009713453132588635, 'mean_word_length': 3.5982142857142856, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6867975', 'n_tokens_mistral': 773, 'n_tokens_neox': 742, 'n_words': 163}