blob: 8a84575bb10d30749d8acdc021a5627ce9eff7a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# app/controllers/request_game_controller.rb:
# The 'categorise old requests' game
#
# 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.9 2009-10-19 22:06:54 francis Exp $
class RequestGameController < ApplicationController
def play
session[:request_game] = Time.now
old = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"])
@missing = old.size
@total = InfoRequest.count
@done = @total - @missing
@percentage = (@done.to_f / @total.to_f * 10000).round / 100.0
@requests = old.sort_by{ rand }.slice(0..2)
if @missing == 0
flash[:notice] = _('<p>All done! Thank you very much for your help.</p><p>There are <a href="{{helpus_url}}">more things you can do</a> to help {{site_name}}.</p>',
:helpus_url => help_credits_path+"#helpus",
:site_name => site_name)
end
@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
def show
url_title = params[:url_title]
if !authenticated?(
:web => _("To play the request categorisation game"),
:email => _("Then you can play the request categorisation game."),
:email_subject => _("Play the request categorisation game")
)
# do nothing - as "authenticated?" has done the redirect to signin page for us
return
end
redirect_to show_request_url(:url_title => url_title)
end
def stop
session[:request_game] = nil
flash[:notice] = _('Thank you for helping us keep the site tidy!')
redirect_to frontpage_url
end
end
|