<commit_before>class Api::V1::ComplaintsController < ApplicationController
  def index
    @complaints = Complaint.order(:time_of_complaint)[0...100]
    render json: @complaints
  end

  def create
  end

  def show
    @complaint = Complaint.find_by(id: params[:id])
    render json: @complaint
  end

  def search
    if !params[:results]
      params[:results] = 100
    end
    @complaints = Complaint.where("complaint_type ILIKE ?", params[:complaint_type]).order(:time_of_complaint)[0...params[:results].to_i]
    render json: @complaints
  end
end<commit_msg>improve flexibility of complaints search<commit_after>class Api::V1::ComplaintsController < ApplicationController
  def index
    @complaints = Complaint.order(:time_of_complaint)[0...100]
    render json: @complaints
  end

  def create
  end

  def show
    @complaint = Complaint.find_by(id: params[:id])
    render json: @complaint
  end

  def search
    if !params[:results]
      params[:results] = 100
    end
    if !!params[:complaint_type]
      complaints = Complaint.where("complaint_type ILIKE ?", params[:complaint_type])

    else
      complaints = Complaint.all
    end
    @complaints = complaints.order(:time_of_complaint)[0...params[:results].to_i]
    render json: @complaints
  end
end
{'fraction_non_alphanumeric': 0.11137254901960784, 'fraction_numerical': 0.01411764705882353, 'mean_word_length': 3.8150943396226413, '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': '4936153', 'n_tokens_mistral': 445, 'n_tokens_neox': 381, 'n_words': 89}