<commit_before>module ApplicationHelper

  def display_address address
    street = address.try(:_street)
    parent_address = address.try(:parent_address).present? ? address.try(:_parent_address) : nil
    address_lines = [address, parent_address, street].
                    compact.
                    map(&:name).
                    map(&:strip).
                    select(&:present?).
                    map(&:downcase).
                    map(&:titlecase)
    lines = address_lines + [
      street.try(:_place).try(:name)
    ]
    lines.
    compact.
    join('<br />').
    html_safe
  end

  def age_range school
    [school.minimum_age, school.maximum_age].join(' to ')
  end

  def religious_characters school
    if school.religious_characters.present?
      school._religious_characters.map(&:name).join(", ")
    else
      'Does not apply'
    end
  end

  def record_url item
    "https://#{item.register}.#{item.phase}.openregister.org/record/#{item.record}"
  end

  def school_authority school
    authority = school.try(:_school_authority_eng)
    authority.try(:_organisation).try(:name) || authority.try(:name)
  end

  def school_type school
    case school._organisation.class.name
    when 'OpenRegister::SchoolType'
      school._organisation.name
    else
      school._organisation._school_type.name
    end
  end

  def school_phase school
    if school.school_phase.present?
      school._school_phase.try(:name)
    else
      "Not applicable"
    end
  end

  def headteacher school
    if school.try(:headteacher).present?
      school.headteacher
    elsif school.try(:end_date).present?
      ''
    else
      'Not yet notified'
    end
  end

end
<commit_msg>Handle school_phase renamed to school_phases<commit_after>module ApplicationHelper

  def display_address address
    street = address.try(:_street)
    parent_address = address.try(:parent_address).present? ? address.try(:_parent_address) : nil
    address_lines = [address, parent_address, street].
                    compact.
                    map(&:name).
                    map(&:strip).
                    select(&:present?).
                    map(&:downcase).
                    map(&:titlecase)
    lines = address_lines + [
      street.try(:_place).try(:name)
    ]
    lines.
    compact.
    join('<br />').
    html_safe
  end

  def age_range school
    [school.minimum_age, school.maximum_age].join(' to ')
  end

  def religious_characters school
    if school.religious_characters.present?
      school._religious_characters.map(&:name).join(", ")
    else
      'Does not apply'
    end
  end

  def record_url item
    "https://#{item.register}.#{item.phase}.openregister.org/record/#{item.record}"
  end

  def school_authority school
    authority = school.try(:_school_authority_eng)
    authority.try(:_organisation).try(:name) || authority.try(:name)
  end

  def school_type school
    case school._organisation.class.name
    when 'OpenRegister::SchoolType'
      school._organisation.name
    else
      school._organisation._school_type.name
    end
  end

  def school_phase school
    if school.school_phases.present?
      school._school_phases.map{|p| p.try(:name)}.join(', ')
    else
      "Not applicable"
    end
  end

  def headteacher school
    if school.try(:headteacher).present?
      school.headteacher
    elsif school.try(:end_date).present?
      ''
    else
      'Not yet notified'
    end
  end

end

{'fraction_non_alphanumeric': 0.1083501878069922, 'fraction_numerical': 0.0, 'mean_word_length': 2.444776119402985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1987064', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1020, 'n_words': 203}