projects
/
selectricity-live
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f34ba91
)
Add nil-guards to the graphs
author
John Dong
<jdong@mit.edu>
Thu, 16 Aug 2007 20:54:46 +0000
(16:54 -0400)
committer
John Dong
<jdong@mit.edu>
Thu, 16 Aug 2007 20:54:46 +0000
(16:54 -0400)
app/controllers/graph_controller.rb
patch
|
blob
|
history
diff --git
a/app/controllers/graph_controller.rb
b/app/controllers/graph_controller.rb
index bbd5cd79f9f4934d0e9f878046e8f88851a41155..8b617da9c19e163db72d3b84b362840d14a370c4 100644
(file)
--- a/
app/controllers/graph_controller.rb
+++ b/
app/controllers/graph_controller.rb
@@
-82,6
+82,7
@@
class GraphController < ApplicationController
#pref_tally = make_preference_tally(@election)
#@borda_result = BordaVote.new(pref_tally).result
#pref_tally = make_preference_tally(@election)
#@borda_result = BordaVote.new(pref_tally).result
+ @election.results unless @election.borda_result
data, labels = get_borda_points(@election.borda_result)
graph = GruffGraff.new( :graph_type => Gruff::Bar,
data, labels = get_borda_points(@election.borda_result)
graph = GruffGraff.new( :graph_type => Gruff::Bar,
@@
-169,7
+170,8
@@
class GraphController < ApplicationController
# Now I need to create an array with all the times votes were made
election.votes.each do |vote|
# Now I need to create an array with all the times votes were made
election.votes.each do |vote|
- voter_days << Date.parse(vote.time.to_s)
+ next unless vote.time
+ voter_days << Date.parse(vote.time.to_s)
end
voter_days.sort!
end
voter_days.sort!
@@
-215,6
+217,7
@@
class GraphController < ApplicationController
# Will build a graph over time, as each successive interval will have more
# vote objects
election.votes.each do |vote|
# Will build a graph over time, as each successive interval will have more
# vote objects
election.votes.each do |vote|
+ next unless vote.time
buckets.keys.sort.each do |inter|
if vote.time < inter
buckets[inter] << vote
buckets.keys.sort.each do |inter|
if vote.time < inter
buckets[inter] << vote
Benjamin Mako Hill
||
Want to submit a patch?