1 <!-- first, process the results -->
2 <% @election.results! %>
4 <!-- create the necessary variables -->
5 <% candidates = @election.ssd_result.ranked_candidates.flatten -%>
6 <% voters = @election.voters.size %>
7 <% matrix = @election.ssd_result.matrix %>
8 <% victories = @election.ssd_result.victories_and_ties %>
9 <% @names = @election.names_by_id %>
11 <p>Each number in the table below shows how many times the candidate on
12 the left beat the matching candidate on the top. The winner is on the
13 top of the left column.</p>
15 <!-- This table shows how many times each choice was ranked above the other,
17 <div class="result_table">
18 <table class="preftable">
21 <% candidates.each do |candidate| -%>
22 <th><%= white_list(@names[candidate]) -%></th>
26 <% candidates.each do |winner| -%>
28 <th><%= white_list(@names[winner]) %></th>
29 <% candidates.each do |loser| -%>
30 <% if winner == loser -%>
33 <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
35 <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie',
36 :diameter => 25, :share_color => '#74ce00' %>
44 <!-- This table generates a margin of victory -->
46 <p>A simplification of the above data. The winner is on the left; each
47 cell names the defeated candidate and the magnitude of the victory in
50 <div class="result_table">
51 <table class="preftable">
52 <% candidates.each do |victor| %>
54 <th><%= white_list(@names[victor]) %></th>
55 <!-- This is a pretty logic heavy section - think about trying to move it to
56 backend eventually. Change the order of first and second to change the order
57 that things are sorted in. -->
58 <% sorted = victories[victor].sort { |first,second| first[1] <=> second[1] }%>
59 <% sorted.each do |loserpair| %>
60 <td><%= white_list(@names[loserpair[0]]) %>
61 <% if loserpair[1] == 0%>