2015-09-28 17:31:55 +08:00
|
|
|
#coding=utf-8
|
2015-09-29 09:22:57 +08:00
|
|
|
namespace :issue_due_date do
|
2015-09-28 17:31:55 +08:00
|
|
|
desc "send a message for Issue'due_date deadline"
|
2015-09-29 09:22:57 +08:00
|
|
|
task :end_time => :environment do
|
2015-09-28 17:31:55 +08:00
|
|
|
contrast_time = Time.now - 86400
|
2015-09-29 09:22:57 +08:00
|
|
|
issues = Issue.where("due_date >=? and due_date <=?",contrast_time,Time.now)
|
2015-09-28 17:31:55 +08:00
|
|
|
issues.each do |issue|
|
|
|
|
if ForgeMessage.where("forge_message_type =? and forge_message_id =? and status =?", "Issue", issue.id, 1).first.nil?
|
|
|
|
recipients = []
|
|
|
|
assigner = User.find(issue.assigned_to_id)
|
|
|
|
recipients << issue.author
|
|
|
|
recipients << assigner
|
|
|
|
recipients.each do |r|
|
2015-09-29 09:22:57 +08:00
|
|
|
issue.forge_messages << ForgeMessage.new(:user_id => r.id, :project_id => issue.project_id, :viewed => false, :status => 1)
|
2015-09-28 17:31:55 +08:00
|
|
|
# 发送邮件通知
|
|
|
|
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|