Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in xml/htdocs/proj/en/council/voting-logs: council-2007-grapher.rb.txt council-2007-vote-distribution.txt
Date: Tue, 18 Sep 2007 20:31:39
Message-Id: E1IXjbt-0003Kk-GD@stork.gentoo.org
1 vapier 07/09/18 20:23:53
2
3 Added: council-2007-grapher.rb.txt
4 council-2007-vote-distribution.txt
5 Log:
6 graphs for 2007
7
8 Revision Changes Path
9 1.1 xml/htdocs/proj/en/council/voting-logs/council-2007-grapher.rb.txt
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/council/voting-logs/council-2007-grapher.rb.txt?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/council/voting-logs/council-2007-grapher.rb.txt?rev=1.1&content-type=text/plain
13
14 Index: council-2007-grapher.rb.txt
15 ===================================================================
16 #!/usr/bin/ruby
17
18 ResultsFile = "council-2007-master.txt"
19 RankingsFile = "council-2007-rank.txt"
20 ScaleSize = 10
21 HeightScale = 7
22 BarHeight = 8
23
24 # Get all candidate names and initialise their vote count
25 candidates = Hash.new
26 ballots = Hash.new
27 File.open ResultsFile, "r" do | file |
28 file.each_line do | line |
29 next if line =~ /^-/
30 line.split(%r/\s+/).each do | person |
31 candidates[person] = [0] * ScaleSize unless candidates[person]
32 end
33 end
34
35 file.seek(0, IO::SEEK_SET)
36
37 key = false
38 file.each_line do | line |
39 if line =~ %r/^-/
40 key = line.split(/\s+/).grep(/^[a-fA-F0-9]{4}$/)[0]
41 ballots[key] = []
42 else
43 raise "key not set yet" unless key
44 ballots[key].push line.chomp.split(/\s+/)
45 end
46 end
47 end
48
49 # Add in missing candidates
50 ballots.keys.each do | key |
51 append_candidates = candidates.keys.dup
52 ballots[key].flatten.each do | candidate |
53 append_candidates.delete_if do | item |
54 item == candidate
55 end
56 end
57 unless append_candidates.empty?
58 ballots[key].push append_candidates
59 end
60 end
61
62 # Calculate distributions
63 ballots.each_pair do | ballot, results |
64 scale_by = ScaleSize / (0.0 + results.length)
65 results.each_with_index do | result, index |
66 place = (scale_by * index.to_f).to_i
67 raise "out of range" unless (0..ScaleSize - 1).include? place
68 result.each do | candidate |
69 candidates[candidate][place] += 1
70 end
71 end
72 end
73
74 # Read in rankings
75 rankings = []
76 File.open RankingsFile, "r" do | file |
77 file.each_line do | line |
78 key = line.split(/\s+/)[0]
79 rankings << key
80 end
81 end
82
83
84 # Display distributions
85 candidates.keys.sort do | a, b |
86 rankings << a unless rankings.index a
87 rankings << b unless rankings.index b
88 (rankings.index a) <=> (rankings.index b)
89 end.each do | candidate |
90 puts " " + candidate + " (" + (rankings.index(candidate) + 1).to_s + ")"
91 BarHeight.downto(0) do | height |
92 print "|"
93 candidates[candidate].each do | value |
94 if value > (height * HeightScale)
95 print "#"
96 else
97 print " "
98 end
99 end
100 puts
101 end
102 puts "+" + ("-" * ScaleSize)
103 puts
104 end
105
106
107
108
109 1.1 xml/htdocs/proj/en/council/voting-logs/council-2007-vote-distribution.txt
110
111 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/council/voting-logs/council-2007-vote-distribution.txt?rev=1.1&view=markup
112 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/council/voting-logs/council-2007-vote-distribution.txt?rev=1.1&content-type=text/plain
113
114 Index: council-2007-vote-distribution.txt
115 ===================================================================
116 vapier (1)
117 |
118 |
119 |#
120 |#
121 |#
122 |#
123 |#
124 |### # ##
125 |##########
126 +----------
127
128 dberkholz (2)
129 |
130 |
131 |
132 |#
133 |#
134 |#
135 |##
136 |### ## #
137 |##########
138 +----------
139
140 uberlord (3)
141 |
142 |
143 |
144 |
145 |
146 |#
147 |### #
148 |###### #
149 |##########
150 +----------
151
152 flameeyes (4)
153 |
154 |
155 |
156 |
157 |
158 |
159 |# ## # #
160 |#### # ##
161 |##########
162 +----------
163
164 lu_zero (5)
165 |
166 |
167 |
168 |
169 |
170 |
171 | # # #
172 |# #######
173 |##########
174 +----------
175
176 betelgeuse (6)
177 |
178 |
179 |
180 |
181 |
182 |
183 |# #
184 |# #######
185 |##########
186 +----------
187
188 amne (7)
189 |
190 |
191 |
192 |
193 |
194 | #
195 |# ##
196 |#### ####
197 |##########
198 +----------
199
200 jokey (8)
201 |
202 |
203 |
204 |
205 |
206 |
207 |# # #
208 |### ####
209 |##########
210 +----------
211
212 jaervosz (9)
213 |
214 |
215 |
216 |
217 |
218 |
219 | # ###
220 | ### ####
221 |##########
222 +----------
223
224 dertobi123 (10)
225 |
226 |
227 |
228 |
229 |
230 |
231 |# ###
232 |# # ####
233 |##########
234 +----------
235
236 welp (11)
237 |
238 |
239 |
240 |
241 | #
242 | #
243 | ## #
244 | # ####
245 |##########
246 +----------
247
248 christel (12)
249 |
250 |
251 |
252 |
253 | #
254 | #
255 | ##
256 |## # #####
257 |##########
258 +----------
259
260
261
262
263 --
264 gentoo-commits@g.o mailing list