27 lines
1.1 KiB
Ruby
27 lines
1.1 KiB
Ruby
#coding=utf-8
|
|
|
|
namespace :contest_work_publishtime do
|
|
desc "start publish contest_work and end contest_work"
|
|
task :publish => :environment do
|
|
puts "--------------------------------contest_work_publish start"
|
|
Rails.logger.info("log--------------------------------contest_work_publish start")
|
|
homework_commons = Work.where("publish_time = '#{Date.today}'")
|
|
homework_commons.each do |homework|
|
|
if homework.work_status == 0
|
|
homework.update_column('work_status', 1)
|
|
|
|
contest = homework.contest
|
|
contest.contest_members.each do |m|
|
|
homework.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => nil)
|
|
end
|
|
if homework.contest_acts.size == 0
|
|
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
|
|
end
|
|
# 邮件通知
|
|
# Mailer.run.homework_added(homework)
|
|
end
|
|
end
|
|
Rails.logger.info("log--------------------------------contest_work_publish end")
|
|
puts "--------------------------------contest_work_publish end"
|
|
end
|
|
end |