socialforge/lib/tasks/exercise_publish.rake

19 lines
549 B
Ruby
Raw Normal View History

2015-12-03 19:08:15 +08:00
#coding=utf-8
namespace :exercise_publish do
desc "publish exercise and end exercise"
task :publish => :environment do
exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
end
end
task :end => :environment do
exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
end
end