<commit_before>class AnswersController < ApplicationController
  include AnswerObjectToGraph
  include ApplicationHelper

  before_action :authenticate_user!
  before_action :find_question, only: [:new, :create]
  before_action :find_answer, only: [:show, :show_as_raw, :log]
  before_action :save_answer_url, only: [:show]

  def index
    date_range = split_date_range

    if params[:correct]
      correct = params[:correct] == "true" ? true : false
    else
      correct = nil
    end

    @answers = Answer
      .where(user: current_user)
      .by_team(params[:teams])
      .by_question(params[:questions])
      .between_dates(date_range[0], date_range[1])
      .correct_status(correct)
      .order(created_at: :desc)
      .paginate(page: params[:page], per_page: 15)
  end

  def new
    @answer = Answer.new
    @team = Team.find(params[:team_id])

    selected_answer = Answer.find_by(id: params[:answer_id])
    @content =  ""
    @results = []

    if selected_answer<commit_msg>Fixed bug in answers search<commit_after>class AnswersController < ApplicationController
  include AnswerObjectToGraph
  include ApplicationHelper

  before_action :authenticate_user!
  before_action :find_question, only: [:new, :create]
  before_action :find_answer, only: [:show, :show_as_raw, :log]
  before_action :save_answer_url, only: [:show]

  def index
    date_range = split_date_range

    unless params[:correct].blank?
      correct = params[:correct] == "true" ? true : false
    else
      correct = nil
    end

    @answers = Answer
      .where(user: current_user)
      .by_team(params[:teams])
      .by_question(params[:questions])
      .between_dates(date_range[0], date_range[1])
      .correct_status(correct)
      .order(created_at: :desc)
      .paginate(page: params[:page], per_page: 15)
  end

  def new
    @answer = Answer.new
    @team = Team.find(params[:team_id])

    selected_answer = Answer.find_by(id: params[:answer_id])
    @content =  ""
    @results = []

    if selected_answer
{'fraction_non_alphanumeric': 0.11479465611083622, 'fraction_numerical': 0.0039584364176150424, 'mean_word_length': 3.6164383561643834, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '655022', 'n_tokens_mistral': 669, 'n_tokens_neox': 642, 'n_words': 139}