From: John Dong Date: Thu, 30 Aug 2007 23:14:55 +0000 (-0400) Subject: Merge jdong X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/c3cd161cbcf0f2e496fdc7888a156907188b8932?hp=e7df11018ea1e15f8671f948126632be3ac86e84 Merge jdong --- diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index e8adcf0..524d743 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -25,6 +25,10 @@ class AccountController < ApplicationController flash[:notice] = "Logged in successfully" end end + + def forgot_password + raise "Not Implemented!" + end def signup @user = User.new(params[:user]) diff --git a/app/models/election.rb b/app/models/election.rb index 7fa138e..99d64f9 100644 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -88,8 +88,28 @@ class Election < ActiveRecord::Base longdesc.length > 0 ? longdesc : nil end - #Calculate Election Results + #Calculate results if not in memcache def results + # Assignment is intentional + if Cache and c = Cache.get("election_results:#{id}:#{self.votes.length}") + @plurality_result = c['plurality'] + @approval_result = c['approval'] + @condorcet_result = c['condorcet'] + @ssd_result = c['ssd'] + @borda_result = c['borda'] + return c + elsif Cache + # memcache is available, but missed. + results = self.results! + Cache.set("election_results:#{id}:#{self.votes.length}", results) + return results + else + return self.results! + end + end + + #Always Calculate Election Results + def results! # initalize the tallies to empty arrays preference_tally = Array.new plurality_tally = Array.new @@ -129,7 +149,6 @@ class Election < ActiveRecord::Base names end - end diff --git a/config/environment.rb b/config/environment.rb index 5ea9f10..fcabdd8 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -65,7 +65,6 @@ require 'uniq_token' require 'randarray' require 'gruff-0.2.8/lib/gruff' require 'sparklines' - require 'rubyvote' ELECTION_TYPES = {'ssd' => "Schulze Sequential Dropping", 'plurality' => "Plurality/First Past the Post", diff --git a/config/environments/development.rb b/config/environments/development.rb index 12a3e04..198c2bd 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,6 @@ # Settings specified here will take precedence over those in config/environment.rb - +#disable memcache +Cache=nil # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. diff --git a/config/environments/production.rb b/config/environments/production.rb index cb295b8..3192ef5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,5 +1,8 @@ # Settings specified here will take precedence over those in config/environment.rb - +# +#Enable memcache +require('memcache') +Cache=MemCache.new('localhost', :compression => true) # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true diff --git a/config/environments/test.rb b/config/environments/test.rb index 7c2f617..a1a2608 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,6 @@ # Settings specified here will take precedence over those in config/environment.rb - +#disable memcache +Cache=nil # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped diff --git a/public/stylesheets/ie6hacks.css b/public/stylesheets/ie6hacks.css index 9aa3422..eefd731 100644 --- a/public/stylesheets/ie6hacks.css +++ b/public/stylesheets/ie6hacks.css @@ -24,7 +24,7 @@ div#bar-right { clear: right; } -ol { +li.moveable { list-style-type: none; }