socialforge/lib/tasks/issue_due_date.rake

24 lines
887 B
Ruby
Raw Normal View History

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)
2016-01-22 09:55:58 +08:00
unless assigner.id == issue.author.id
recipients << issue.author
end
2015-09-28 17:31:55 +08:00
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
end
end
2016-01-22 20:26:44 +08:00
# issue截止时间邮件提醒
Mailer.issue_due_date(issue).deliver
2015-09-28 17:31:55 +08:00
end
end
end