cluster configuration for new machine
[selectricity-live] / app / views / common / _pref_tables.rhtml
1 <% candidates = @election.ssd_result.ranked_candidates.flatten -%>
2 <% voters = @election.voters.size %>
3 <% matrix = @election.ssd_result.matrix %>
4 <% victories = @election.ssd_result.victories_and_ties %>
5 <p>Each number in the table below shows how many times the candidate on
6 the left beat the matching candidate on the top. The winner is on the
7 top of the left column.</p>
8
9 <!-- This table shows how many times each choice was ranked above the other, 
10         with percentages-->
11 <div class="result_table">
12 <table class="preftable">
13   <tr>
14         <td></td>
15         <% candidates.each do |candidate| -%>
16           <th><%= white_list(@names[candidate]) -%></th>
17   <% end -%>
18  </tr>
19
20 <% candidates.each do |winner| -%>
21   <tr>
22         <th><%= white_list(@names[winner]) %></th>
23   <% candidates.each do |loser| -%> 
24     <% if winner == loser -%>
25       <td> -- </td>
26     <% else %>        
27       <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
28           <%= wins %>
29               <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', 
30                                  :diameter => 25, :share_color => '#74ce00' %>
31           </td>
32     <% end -%>
33   <% end -%>
34  </tr>
35 <% end -%>
36 </table>
37 </div>
38 <!-- This table generates a margin of victory -->
39
40 <p>A simplification of the above data. The winner is on the left; each
41 cell names the defeated candidate and the magnitude of the victory in
42 parenthesis.</p>
43
44 <div class="result_table">
45 <table class="preftable">
46   <% candidates.each do |victor| %>
47   <tr>
48     <th><%= white_list(@names[victor]) %></th>
49 <!-- This is a pretty logic heavy section - think about trying to move it to 
50         backend eventually. Change the order of first and second to change the order 
51         that things are sorted in. -->
52         <% sorted = victories[victor].sort { |first,second| first[1] <=> second[1] }%>
53         <% sorted.each do |loserpair| %>
54         <td><%= white_list(@names[loserpair[0]]) %> 
55             <% if loserpair[1] == 0%>
56                   Tied!
57                 <% else -%>
58                   (<%= loserpair[1] %>)
59                 <% end -%>
60         </td>
61         <% end -%>
62   </tr>
63   <% end -%>
64 </table>
65 </div>
66
67

Benjamin Mako Hill || Want to submit a patch?