diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -37,7 +37,9 @@ end def self.find_available_problems - find(:all, :conditions => {:available => true}, :order => "date_added DESC") + find(:all, + :conditions => {:available => true}, + :order => "updated_at DESC") end # TODO: may try to optimize this using cache diff --git a/app/views/main/list.html.haml b/app/views/main/list.html.haml --- a/app/views/main/list.html.haml +++ b/app/views/main/list.html.haml @@ -37,6 +37,6 @@ CodejomTimeout.updateProblemMessages(); CodejomTimeout.registerRefreshEvent(); -= periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list') += periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list', :frequency => '3') diff --git a/db/migrate/20100210012432_add_timestamp_to_problems.rb b/db/migrate/20100210012432_add_timestamp_to_problems.rb new file mode 100644 --- /dev/null +++ b/db/migrate/20100210012432_add_timestamp_to_problems.rb @@ -0,0 +1,9 @@ +class AddTimestampToProblems < ActiveRecord::Migration + def self.up + add_column :problems, :updated_at, :timestamp + end + + def self.down + remove_column :problems, :updated_at + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20100209145331) do +ActiveRecord::Schema.define(:version => 20100210012432) do create_table "announcements", :force => true do |t| t.string "author" @@ -84,16 +84,17 @@ end create_table "problems", :force => true do |t| - t.string "name", :limit => 30 - t.string "full_name" - t.integer "full_score" - t.date "date_added" - t.boolean "available" - t.string "url" - t.integer "description_id" - t.boolean "test_allowed" - t.boolean "output_only" - t.integer "level", :default => 0 + t.string "name", :limit => 30 + t.string "full_name" + t.integer "full_score" + t.date "date_added" + t.boolean "available" + t.string "url" + t.integer "description_id" + t.boolean "test_allowed" + t.boolean "output_only" + t.integer "level", :default => 0 + t.datetime "updated_at" end create_table "rights", :force => true do |t|