]> projects.mako.cc - selectricity-live/blobdiff - app/controllers/quickvote_controller.rb
The other election methods will now display the winner they elected in their own
[selectricity-live] / app / controllers / quickvote_controller.rb
index d8d3d59e59139b9499c70c514cc77b8442203359..b9c790f40f872fa99048f10aec38cc76abc348a1 100644 (file)
@@ -168,7 +168,14 @@ class QuickvoteController < ApplicationController
     @election=QuickVote.ident_to_quickvote(params[:id])
     @election.voters.each do |voter|
       next unless voter.ipaddress
     @election=QuickVote.ident_to_quickvote(params[:id])
     @election.voters.each do |voter|
       next unless voter.ipaddress
-      location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
+      location=nil
+      if Cache and location=Cache.get("GEO:#{voter.ipaddress}")
+      elsif Cache
+        location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
+        Cache.set "GEO:#{voter.ipaddress}", location
+      else
+        location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
+      end
       next unless location.lng and location.lat
 
       unless center
       next unless location.lng and location.lat
 
       unless center

Benjamin Mako Hill || Want to submit a patch?