<commit_before>class AdminController < ApplicationController
  before_filter :authorized?

  def authorized?
    unless user_signed_in? && current_user.admin
      redirect_to dashboard_path
    end
  end

  def index
    @users = User.all

    sql =
      'SELECT count(DISTINCT user_id) count '+
      'FROM interactions '+
      'WHERE created_on > date_sub("'+ Time.now.utc.to_s() +'", INTERVAL 20 MINUTE) '+
      'AND user_id IS NOT NULL'

    @user_count = Interaction.connection.select_value(sql)
  end

  def edit_user
  end

  def update_user
    @user.update_attributes(params[:user])
    @user.save!<commit_msg>Better SQL query for online users count using UTC_TIMESTAMP()<commit_after>class AdminController < ApplicationController
  before_filter :authorized?

  def authorized?
    unless user_signed_in? && current_user.admin
      redirect_to dashboard_path
    end
  end

  def index
    @users = User.all

    sql =
      'SELECT count(DISTINCT user_id) count '+
      'FROM interactions '+
      'WHERE created_on > date_sub(UTC_TIMESTAMP(), INTERVAL 20 MINUTE) '+
      'AND user_id IS NOT NULL'

    @user_count = Interaction.connection.select_value(sql)
  end

  def edit_user
  end

  def update_user
    @user.update_attributes(params[:user])
    @user.save!
{'fraction_non_alphanumeric': 0.08658346333853355, 'fraction_numerical': 0.0031201248049922, 'mean_word_length': 3.3639455782312924, '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': '505140', 'n_tokens_mistral': 423, 'n_tokens_neox': 390, 'n_words': 100}