<commit_before>class FeedsController < ApplicationController
  def mp_info
    @members = Member.in_australian_house(params[:house] || 'representatives').joins(:member_info).order(:entered_house, :last_name, :first_name, :constituency)
    @most_recent_division = Division.most_recent_date

    @current_members_by_attendance = Ranker.rank(@members.current, by: lambda{|m| m.person.attendance_fraction})
    @current_members_count = @members.current.count

    members_with_rebellions = @members.current.to_a.delete_if { |m| !m.person.rebellions_fraction }
    @current_members_by_rebellions = Ranker.rank(members_with_rebellions, by: lambda {|m| m.person.rebellions_fraction})
    @members_with_rebellions_and_party_whip_count = members_with_rebellions.select { |m| m.has_whip? }.count
  end

  def mpdream_info
    @policy = Policy.find(params[:id])

    # FIXME: Using SQL to match PHP, see #211 for detailed description
    sql = "select policy_person_distances.person_id, distance_a, distance_b, members.id as member_id,
           (nvotessame + nvotessamestrong + nvotesdiffer + nvotesdifferstrong) as both_voted,
           (nvotesabsent + nvotesabsentstrong) as absent
           from policy_person_distances, members
           where policy_id = '#{@policy.id}' and
           members.person_id = policy_person_distances.person_id"
    @policy_person_distances = PolicyPersonDistance.connection.select_all(sql)
  end
end<commit_msg>Make order of results deterministic<commit_after>class FeedsController < ApplicationController
  def mp_info
    @members = Member.in_australian_house(params[:house] || 'representatives').joins(:member_info).order(:entered_house, :last_name, :first_name, :constituency)
    @most_recent_division = Division.most_recent_date

    @current_members_by_attendance = Ranker.rank(@members.current, by: lambda{|m| m.person.attendance_fraction})
    @current_members_count = @members.current.count

    members_with_rebellions = @members.current.to_a.delete_if { |m| !m.person.rebellions_fraction }
    @current_members_by_rebellions = Ranker.rank(members_with_rebellions, by: lambda {|m| m.person.rebellions_fraction})
    @members_with_rebellions_and_party_whip_count = members_with_rebellions.select { |m| m.has_whip? }.count
  end

  def mpdream_info
    @policy = Policy.find(params[:id])

    # FIXME: Using SQL to match PHP, see #211 for detailed description
    sql = "select policy_person_distances.person_id, distance_a, distance_b, members.id as member_id,
           (nvotessame + nvotessamestrong + nvotesdiffer + nvotesdifferstrong) as both_voted,
           (nvotesabsent + nvotesabsentstrong) as absent
           from policy_person_distances, members
           where policy_id = '#{@policy.id}' and
           members.person_id = policy_person_distances.person_id order by member_id"
    @policy_person_distances = PolicyPersonDistance.connection.select_all(sql)
  end
end
{'fraction_non_alphanumeric': 0.09305508039685255, 'fraction_numerical': 0.0020526855969893944, 'mean_word_length': 4.919028340080971, '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': '7230233', 'n_tokens_mistral': 955, 'n_tokens_neox': 933, 'n_words': 170}