<commit_before>module SearchResultHelpers
  private

  def fees
    object.fees&.split(',')&.map { |fee| fee.split('~') }
  end

  def graduated_fee_codes
    object.graduated_fee_types&.split(',')
  end

  def fee_is_interim_type
    fees&.map do |fee|
      [
        fee[2].eql?('Fee::InterimFeeType'),
        fee[1].downcase.in?(['effective pcmh', 'trial start', 'retrial new solicitor', 'retrial start'])
      ].all?
    end&.any?
  end

  def contains_risk_based_fee
    (contains_risk_based_final_fee || (contains_risk_based_transfer_fee && up_to_and_inc_pcmh_transfer?))
  end

  def contains_risk_based_final_fee
    fees&.map do |fee|
      [
        fee[0].to_i.between?(1, 50),
        fee[1].in?(['Discontinuance', 'Guilty plea']),
        fee[2].eql?('Fee::GraduatedFeeType')
      ]&.all?
    end&.any?
  end

  def contains_risk_based_transfer_fee
    fees&.map do |fee|
      [
        fee[0].to_i.between?(1, 50),
        fee[2].eql?('Fee::TransferFeeType')
      ]&.all?
    end&.any?
  end

  def contains_fee_of_type(fee_type_description)
    fees&.map do |fee|
      [
        fee[2].eql?('Fee::InterimFeeType'),
        fee[1].eql?(fee_type_description)
      ].all?
    end&.any?
  end

  def risk_based_class_letter
    object.class_letter&.in?(%w[E F G H I])
  end

  def interim_claim?<commit_msg>Changes to PPE for RBB filter<commit_after>module SearchResultHelpers
  private

  def fees
    object.fees&.split(',')&.map { |fee| fee.split('~') }
  end

  def graduated_fee_codes
    object.graduated_fee_types&.split(',')
  end

  def fee_is_interim_type
    fees&.map do |fee|
      [
        fee[2].eql?('Fee::InterimFeeType'),
        fee[1].downcase.in?(['effective pcmh', 'trial start', 'retrial new solicitor', 'retrial start'])
      ].all?
    end&.any?
  end

  def contains_risk_based_fee
    (contains_risk_based_final_fee || (contains_risk_based_transfer_fee && up_to_and_inc_pcmh_transfer?))
  end

  def contains_risk_based_final_fee
    fees&.map do |fee|
      [
        fee[0].to_i.between?(0, 49),
        fee[1].in?(['Discontinuance', 'Guilty plea']),
        fee[2].eql?('Fee::GraduatedFeeType')
      ]&.all?
    end&.any?
  end

  def contains_risk_based_transfer_fee
    fees&.map do |fee|
      [
        fee[0].to_i.between?(0, 49),
        fee[2].eql?('Fee::TransferFeeType')
      ]&.all?
    end&.any?
  end

  def contains_fee_of_type(fee_type_description)
    fees&.map do |fee|
      [
        fee[2].eql?('Fee::InterimFeeType'),
        fee[1].eql?(fee_type_description)
      ].all?
    end&.any?
  end

  def risk_based_class_letter
    object.class_letter&.in?(%w[E F G H I])
  end

  def interim_claim?
{'fraction_non_alphanumeric': 0.14842578710644677, 'fraction_numerical': 0.011244377811094454, 'mean_word_length': 2.959940652818991, 'pattern_counts': {'":': 0, '<': 3, '<?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': '524390', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1039, 'n_words': 168}