Description:
problems sorted by update time
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r258:1821e2e3aeb0 - - 4 files changed: 15 inserted, 3 deleted

@@ -0,0 +1,9
1 + class AddTimestampToProblems < ActiveRecord::Migration
2 + def self.up
3 + add_column :problems, :updated_at, :timestamp
4 + end
5 +
6 + def self.down
7 + remove_column :problems, :updated_at
8 + end
9 + end
@@ -28,25 +28,27
28 def random_test_pair(forbidden_numbers=nil)
28 def random_test_pair(forbidden_numbers=nil)
29 if forbidden_numbers.length < test_pair_count
29 if forbidden_numbers.length < test_pair_count
30 begin
30 begin
31 test_num = 1 + rand(test_pair_count)
31 test_num = 1 + rand(test_pair_count)
32 end while forbidden_numbers!=nil and forbidden_numbers.include? test_num
32 end while forbidden_numbers!=nil and forbidden_numbers.include? test_num
33 else
33 else
34 test_num = 1 + rand(test_pair_count)
34 test_num = 1 + rand(test_pair_count)
35 end
35 end
36 test_pairs.find_by_number test_num
36 test_pairs.find_by_number test_num
37 end
37 end
38
38
39 def self.find_available_problems
39 def self.find_available_problems
40 - find(:all, :conditions => {:available => true}, :order => "date_added DESC")
40 + find(:all,
41 + :conditions => {:available => true},
42 + :order => "updated_at DESC")
41 end
43 end
42
44
43 # TODO: may try to optimize this using cache
45 # TODO: may try to optimize this using cache
44 def self.available_problem_count
46 def self.available_problem_count
45 return Problem.find_available_problems.length
47 return Problem.find_available_problems.length
46 end
48 end
47
49
48 def self.create_from_import_form_params(params, old_problem=nil)
50 def self.create_from_import_form_params(params, old_problem=nil)
49 problem = old_problem || Problem.new
51 problem = old_problem || Problem.new
50 import_params = Problem.extract_params_and_check(params, problem)
52 import_params = Problem.extract_params_and_check(params, problem)
51
53
52 if not problem.valid?
54 if not problem.valid?
@@ -28,15 +28,15
28 = render :partial => 'problem', :collection => @problems
28 = render :partial => 'problem', :collection => @problems
29
29
30 %br{:clear=>'both'}/
30 %br{:clear=>'both'}/
31 %hr/
31 %hr/
32
32
33 %script{:type => 'text/javascript'}
33 %script{:type => 'text/javascript'}
34 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
34 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
35 Announcement.registerRefreshEventTimer();
35 Announcement.registerRefreshEventTimer();
36 = render :partial => 'submission_timeouts'
36 = render :partial => 'submission_timeouts'
37 CodejomTimeout.updateProblemMessages();
37 CodejomTimeout.updateProblemMessages();
38 CodejomTimeout.registerRefreshEvent();
38 CodejomTimeout.registerRefreshEvent();
39
39
40 - = periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list')
40 + = periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list', :frequency => '3')
41
41
42
42
@@ -1,24 +1,24
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of Active Record to incrementally modify your database, and
2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 # then regenerate this schema definition.
3 # then regenerate this schema definition.
4 #
4 #
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 # to create the application database on another system, you should be using db:schema:load, not running
6 # to create the application database on another system, you should be using db:schema:load, not running
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 #
9 #
10 # It's strongly recommended to check this file into your version control system.
10 # It's strongly recommended to check this file into your version control system.
11
11
12 - ActiveRecord::Schema.define(:version => 20100209145331) do
12 + ActiveRecord::Schema.define(:version => 20100210012432) do
13
13
14 create_table "announcements", :force => true do |t|
14 create_table "announcements", :force => true do |t|
15 t.string "author"
15 t.string "author"
16 t.text "body"
16 t.text "body"
17 t.boolean "published"
17 t.boolean "published"
18 t.datetime "created_at"
18 t.datetime "created_at"
19 t.datetime "updated_at"
19 t.datetime "updated_at"
20 t.boolean "frontpage", :default => false
20 t.boolean "frontpage", :default => false
21 t.boolean "contest_only", :default => false
21 t.boolean "contest_only", :default => false
22 t.string "title"
22 t.string "title"
23 end
23 end
24
24
@@ -85,24 +85,25
85
85
86 create_table "problems", :force => true do |t|
86 create_table "problems", :force => true do |t|
87 t.string "name", :limit => 30
87 t.string "name", :limit => 30
88 t.string "full_name"
88 t.string "full_name"
89 t.integer "full_score"
89 t.integer "full_score"
90 t.date "date_added"
90 t.date "date_added"
91 t.boolean "available"
91 t.boolean "available"
92 t.string "url"
92 t.string "url"
93 t.integer "description_id"
93 t.integer "description_id"
94 t.boolean "test_allowed"
94 t.boolean "test_allowed"
95 t.boolean "output_only"
95 t.boolean "output_only"
96 t.integer "level", :default => 0
96 t.integer "level", :default => 0
97 + t.datetime "updated_at"
97 end
98 end
98
99
99 create_table "rights", :force => true do |t|
100 create_table "rights", :force => true do |t|
100 t.string "name"
101 t.string "name"
101 t.string "controller"
102 t.string "controller"
102 t.string "action"
103 t.string "action"
103 end
104 end
104
105
105 create_table "rights_roles", :id => false, :force => true do |t|
106 create_table "rights_roles", :id => false, :force => true do |t|
106 t.integer "right_id"
107 t.integer "right_id"
107 t.integer "role_id"
108 t.integer "role_id"
108 end
109 end
You need to be logged in to leave comments. Login now