]> projects.mako.cc - selectricity-live/blobdiff - app/controllers/graphs_controller.rb
Modified the methods in graphs controller so they would work for Selectricity, but...
[selectricity-live] / app / controllers / graphs_controller.rb
index c8108536b214262130f3f5f96134ffced3abaa54..101dc6d6d185ddde9bd184a3b161d981a7643117 100644 (file)
@@ -29,15 +29,15 @@ class GraphsController < ApplicationController
     send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
   end
   
-  #The following section has been pasted directly fromworking pollarize graphs
-  #and hasn't been adopted to fit Selectricity yet
-  
+  #I've started to modify the following section to fit Selectricity, still 
+  #desn't seem towork, issue seems tobe realted to path
   def day_votes
-    @poll = Poll.find(params[:id])
+  
+    @election = Election.find(params[:id])
     line = Gruff::Line.new
     line.title = "Voters Per Day"
     line.font = File.expand_path('/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf', RAILS_ROOT)
-    line.data("#{@poll.name}", voter_days["voters_per_day"] )
+    line.data("#{@election.name}", voter_days["voters_per_day"] )
     line.labels = voter_days["days_hash"]
     line.x_axis_label = "Date"
     line.y_axis_label = "Number of Votes"
@@ -50,22 +50,18 @@ class GraphsController < ApplicationController
   end
   
   def voter_days
-    @poll = Poll.find(params[:id])
+    @election = Election.find(params[:id])
     voter_times = Array.new
     unique_days = Array.new
     voters_per_day = Array.new
     days_hash = Hash.new
     
-    @poll.questions.each do |qstn|
-      qstn.votes.each do |vote|
+    @election.votes.each do |vote|
         voter_times << vote.time unless voter_times.any? {|utime| utime == vote.time}
-      end
     end
+    
     voter_times.sort!
-    #find all times in voter_times with the same date, and then concatenate 
-    #that number onto votes_per_day
-    #
-    #doesn't work jsut yet
+  
     voter_times.each_with_index do |time, index| 
       count = 1
       unless unique_days.any? { |d1| d1.eql?(time.mon.to_s+"/"+time.day.to_s) }
@@ -81,7 +77,7 @@ class GraphsController < ApplicationController
   return { "voters_per_day" => voters_per_day, "days_hash" => days_hash }
    
   end
-  #end copy/pasted section
+  #end section
 
 
 end

Benjamin Mako Hill || Want to submit a patch?