<commit_before>class AnimalsController < ApplicationController
  before_action :set_animal, only: [:show, :edit, :update, :destroy]

  # GET /animals
  # GET /animals.json
  def index
    logger.debug("params are #{params}")
    logger.debug("Group id is #{current_user.group_id}")
    @keywords = (params["keywords"]) || ''
    @page = (params["page"] || 0).to_i
    @pagesize = params["pagesize"]
    @sortby = params["sortby"] || "kennel"
    @sortOrder = params["sortOrder"] || "false"
    @animals = search(@keywords, @page, @pagesize, @sortby, @sortOrder)
    logger.debug("Primary photo is: #{@animals[0].primary_photo}")
    respond_to do |format|
      format.html 
      format.json { render :json => @animals, 
        :methods => [ :kennel, :age, :days_under_care, :animal_type, :intake_type, :gender, :primary_photo ] }
    end
  end

  def search(searchOn, page, pagesize, sortBy, sortOrder)
    sortAs = sortOrder.eql?("true") ? :desc : :asc<commit_msg>DE14: Error when searching on "root" in Animal listing search box<commit_after>class AnimalsController < ApplicationController
  before_action :set_animal, only: [:show, :edit, :update, :destroy]

  # GET /animals
  # GET /animals.json
  def index
    logger.debug("params are #{params}")
    logger.debug("Group id is #{current_user.group_id}")
    @keywords = (params["keywords"]) || ''
    @page = (params["page"] || 0).to_i
    @pagesize = params["pagesize"]
    @sortby = params["sortby"] || "kennel"
    @sortOrder = params["sortOrder"] || "false"
    @animals = search(@keywords, @page, @pagesize, @sortby, @sortOrder)
    respond_to do |format|
      format.html 
      format.json { render :json => @animals, 
        :methods => [ :kennel, :age, :days_under_care, :animal_type, :intake_type, :gender, :primary_photo ] }
    end
  end

  def search(searchOn, page, pagesize, sortBy, sortOrder)
    sortAs = sortOrder.eql?("true") ? :desc : :asc
{'fraction_non_alphanumeric': 0.1603331598125976, 'fraction_numerical': 0.0026028110359187923, 'mean_word_length': 3.9922077922077923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2961198', 'n_tokens_mistral': 655, 'n_tokens_neox': 623, 'n_words': 153}