<commit_before>class AdminController < ApplicationController
  before_action :verify_admin, :except => [:user_feedback, :api_feedback, :users, :recently_invalidated, :index]
  before_action :set_ignored_user, :only => [:ignore, :unignore, :destroy_ignored]

  def index
  end

  def recently_invalidated
    @feedbacks = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:is_invalidated => true).select('posts.title, feedbacks.*').order('feedbacks.invalidated_at DESC').paginate(:page => params[:page], :per_page => 100)

    @users = User.where(:id => @feedbacks.pluck(:invalidated_by)).map { |u| [u.id, u] }.to_h
  end

  def user_feedback
    @user = User.all.where(:id => params[:user_id]).first
    @feedback = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:user_id => @user.id)
    @sources = ['metasmoke']

    if @user.stackoverflow_chat_id.present?
      so_feedback = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:chat_host => "stackoverflow.com", :chat_user_id => @user.stackoverflow_chat_id)
      @feedback = @feedback.or(so_feedback)
      @sources << 'Stack Overflow chat'
    end

    if @user.stackexchange_chat_id.present?
      se_feedback = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:chat_host => "stackexchange.com", :chat_user_id => @user.stackexchange_chat_id)
      @feedback = @feedback.or(se_feedback)
      @sources << 'Stack Exchange chat'
    end

    if @user.meta_stackexchange_chat_id.present?
      mse_feedback = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:chat_host => "meta.stackexchange.com", :chat_user_id => @user.meta_stackexchange_chat_id)
      @feedback = @feedback.or(mse_feedback)
      @sources << 'Meta Stack Exchange chat'
    end

    @feedback = @feedback.order('feedbacks.id DESC').paginate(:page => params[:page], :per_page => 100)
    @feedback_count = @feedback.count
    @invalid_count = @feedback.where(:is_invalidated => true).count<commit_msg>rm unnecessary selections<commit_after>class AdminController < ApplicationController
  before_action :verify_admin, :except => [:user_feedback, :api_feedback, :users, :recently_invalidated, :index]
  before_action :set_ignored_user, :only => [:ignore, :unignore, :destroy_ignored]

  def index
  end

  def recently_invalidated
    @feedbacks = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:is_invalidated => true).select('posts.title, feedbacks.*').order('feedbacks.invalidated_at DESC').paginate(:page => params[:page], :per_page => 100)

    @users = User.where(:id => @feedbacks.pluck(:invalidated_by)).map { |u| [u.id, u] }.to_h
  end

  def user_feedback
    @user = User.all.where(:id => params[:user_id]).first
    @feedback = Feedback.unscoped.joins('inner join posts on feedbacks.post_id = posts.id').where(:user_id => @user.id)
    @sources = ['metasmoke']

    if @user.stackoverflow_chat_id.present?
      @sources << 'Stack Overflow chat'
    end

    if @user.stackexchange_chat_id.present?
      @sources << 'Stack Exchange chat'
    end

    if @user.meta_stackexchange_chat_id.present?
      @sources << 'Meta Stack Exchange chat'
    end

    @feedback = @feedback.order('feedbacks.id DESC').paginate(:page => params[:page], :per_page => 100)
    @feedback_count = @feedback.count
    @invalid_count = @feedback.where(:is_invalidated => true).count
{'fraction_non_alphanumeric': 0.14216107767268557, 'fraction_numerical': 0.0034393809114359416, 'mean_word_length': 4.693311582381729, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, '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': '2996633', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1144, 'n_words': 219}