aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/request_game_controller.rb
diff options
context:
space:
mode:
authorfrancis <francis>2009-10-19 22:06:54 +0000
committerfrancis <francis>2009-10-19 22:06:54 +0000
commit0828775dbee38080a1fe17d1e37d6e000c6f64fc (patch)
tree15a1687c5747d37a2c2c98f4f8225a4cb09096f5 /app/controllers/request_game_controller.rb
parent231b1bfb5f74eff76c59afe083cda17bf593d6e6 (diff)
Top 10!
Diffstat (limited to 'app/controllers/request_game_controller.rb')
-rw-r--r--app/controllers/request_game_controller.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 134a87b73..599a82fd6 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_game_controller.rb,v 1.8 2009-10-14 22:24:16 francis Exp $
+# $Id: request_game_controller.rb,v 1.9 2009-10-19 22:06:54 francis Exp $
class RequestGameController < ApplicationController
@@ -24,21 +24,12 @@ class RequestGameController < ApplicationController
redirect_to frontpage_url
end
- # Work out league table
- status_update_events = InfoRequestEvent.find(:all,
- :conditions => [ "event_type = 'status_update' and created_at >= ?", Time.now() - 28.days ])
- table = Hash.new { |h,k| h[k] = 0 }
- for event in status_update_events
- user_id = event.params[:user_id]
- table[user_id] += 1
- end
- @league_table = []
- for user_id, count in table
- user = User.find(user_id)
- @league_table.push([user, count])
- end
- @league_table.sort! { |a,b| b[1] <=> a[1] }
-
+ @league_table_28_days = InfoRequestEvent.make_league_table(
+ [ "event_type = 'status_update' and created_at >= ?", Time.now() - 28.days ]
+ )[0..10]
+ @league_table_all_time = InfoRequestEvent.make_league_table(
+ [ "event_type = 'status_update'"]
+ )[0..10]
@play_urls = true
end