<commit_before>class InquiriesController < ApplicationController

  helper_method :sort_column, :sort_direction

	def index
    @inquiries = find_inquiries
    @inquiries = @inquiries.order(sort_column + " " + sort_direction)
    @inquiries = @inquiries.paginate(:per_page => 20, :page => params[:page])
  end

  def find_inquiries()   
    inquiries = Inquiry.all 
    inquiries = inquiries.search(params[:search]) if params[:search].present?
    inquiries = inquiries.where(status: params[:status]) if params[:status].present? 
    inquiries = inquiries.where(database: params[:database]) if params[:database].present?
    inquiries = inquiries.where(inquiry_type: params[:inquiry_type]) if params[:inquiry_type].present?

    if params[:filter_date_type].present? 
      inquiries = inquiries.where("#{params[:filter_date_type]} >= ?", params[:date_start]) if params[:date_start].present?

      if params[:date_end].present?
        end_date = Date.parse(params[:date_end]) if params[:date_end]
        end_date = end_date.end_of_day
        inquiries = inquiries.where("#{params[:filter_date_type]} <= ?", end_date) if params[:date_end].present?
      end
      
    end


    # BUG: area of vehicle search doesn't work. For some reason it can search "Other" but not any other area of vehicle types

    # inquiries = inquiries.where(['area_of_vehicle LIKE ?', params[:area_of_vehicle]]) if params[:area_of_vehicle].present?
    # inquiries = inquiries.where(area_of_vehicle: params[:area_of_vehicle]) if params[:area_of_vehicle].present?
      
    inquiries
  end 

  def find_unsubmitted_inquiries(db = nil)
    inquiries = Inquiry.all
    inquiries = inquiries.where(status: 'Received by DEG')
    inquiries = inquiries.where(database: db) if db.present?
    inquiries
  end<commit_msg>added body type filter for export<commit_after>class InquiriesController < ApplicationController

  helper_method :sort_column, :sort_direction

	def index
    @inquiries = find_inquiries
    @inquiries = @inquiries.order(sort_column + " " + sort_direction)
    @inquiries = @inquiries.paginate(:per_page => 20, :page => params[:page])
  end

  def find_inquiries()   
    inquiries = Inquiry.all 
    inquiries = inquiries.search(params[:search]) if params[:search].present?
    inquiries = inquiries.where(status: params[:status]) if params[:status].present? 
    inquiries = inquiries.where(database: params[:database]) if params[:database].present?
    inquiries = inquiries.where(inquiry_type: params[:inquiry_type]) if params[:inquiry_type].present?
    inquiries = inquiries.where(body_type: params[:body_type]) if params[:body_type].present?

    if params[:filter_date_type].present? 
      inquiries = inquiries.where("#{params[:filter_date_type]} >= ?", params[:date_start]) if params[:date_start].present?

      if params[:date_end].present?
        end_date = Date.parse(params[:date_end]) if params[:date_end]
        end_date = end_date.end_of_day
        inquiries = inquiries.where("#{params[:filter_date_type]} <= ?", end_date) if params[:date_end].present?
      end
      
    end


    # BUG: area of vehicle search doesn't work. For some reason it can search "Other" but not any other area of vehicle types

    # inquiries = inquiries.where(['area_of_vehicle LIKE ?', params[:area_of_vehicle]]) if params[:area_of_vehicle].present?
    # inquiries = inquiries.where(area_of_vehicle: params[:area_of_vehicle]) if params[:area_of_vehicle].present?
      
    inquiries
  end 

  def find_unsubmitted_inquiries(db = nil)
    inquiries = Inquiry.all
    inquiries = inquiries.where(status: 'Received by DEG')
    inquiries = inquiries.where(database: db) if db.present?
    inquiries
  end
{'fraction_non_alphanumeric': 0.11960043196544276, 'fraction_numerical': 0.0010799136069114472, 'mean_word_length': 4.416666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6187395', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1087, 'n_words': 241}