<commit_before>class PeopleController < ApplicationController
  def index
    letter_data = Parliament::Request.new.people.a_z_letters.get

    @people = Parliament::Request.new.people.get.sort_by(:family_name, :given_name)
    @letters = letter_data.map(&:value)
  end

  def lookup
    source = params[:source]
    id = params[:id]

    @person = Parliament::Request.new.people.lookup.get(params: { source: source, id: id }).first

    redirect_to person_path(@person.graph_id)
  end

  def show
    person_id = params[:person_id]

    data = Parliament::Request.new.people(person_id).get

    @person, @seat_incumbencies, @house_incumbencies = data.filter(
      'http://id.ukpds.org/schema/Person',
      'http://id.ukpds.org/schema/SeatIncumbency',
      'http://id.ukpds.org/schema/HouseIncumbency'
    )

    @person = @person.first

    @current_incumbency = @seat_incumbencies.select(&:current?).first || @house_incumbencies.select(&:current?).first
    @current_party_membership = @person.party_memberships.select(&:current?).first
  end

  def members<commit_msg>First pass at finding the most_recent_house<commit_after>class PeopleController < ApplicationController
  def index
    letter_data = Parliament::Request.new.people.a_z_letters.get

    @people = Parliament::Request.new.people.get.sort_by(:family_name, :given_name)
    @letters = letter_data.map(&:value)
  end

  def lookup
    source = params[:source]
    id = params[:id]

    @person = Parliament::Request.new.people.lookup.get(params: { source: source, id: id }).first

    redirect_to person_path(@person.graph_id)
  end

  def show
    person_id = params[:person_id]

    data = Parliament::Request.new.people(person_id).get

    @person, @seat_incumbencies, @house_incumbencies = data.filter(
      'http://id.ukpds.org/schema/Person',
      'http://id.ukpds.org/schema/SeatIncumbency',
      'http://id.ukpds.org/schema/HouseIncumbency'
    )

    @person = @person.first

    @current_incumbency = @seat_incumbencies.select(&:current?).first || @house_incumbencies.select(&:current?).first
    @current_party_membership = @person.party_memberships.select(&:current?).first
    most_recent_seat_incumbency = @seat_incumbencies.sort_by(:end_date).last
    most_recent_house_incumbency = @house_incumbencies.sort_by(:end_date).last

    if most_recent_seat_incumbency.end_date > most_recent_house_incumbency.end_date
      @most_recent_house = most_recent_seat_incumbency.house
    else
      @most_recent_house = most_recent_house_incumbency.house
    end
  end

  def members
{'fraction_non_alphanumeric': 0.12231340367330988, 'fraction_numerical': 0.0, 'mean_word_length': 4.278350515463917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4651831', 'n_tokens_mistral': 888, 'n_tokens_neox': 829, 'n_words': 121}