issue截止时间消息提醒

This commit is contained in:
huang 2015-09-29 09:22:57 +08:00
parent 5f26e331c6
commit 0336cc2cf6
1 changed files with 6 additions and 4 deletions

View File

@ -1,17 +1,19 @@
#coding=utf-8
namespace :issue_endtime do
namespace :issue_due_date do
desc "send a message for Issue'due_date deadline"
task :due_date => :environment do
task :end_time => :environment do
contrast_time = Time.now - 86400
issues = Issue.where("due_date >=? and due_date <=? and due_date !=?",contrast_time,Time.now, nil)
issues = Issue.where("due_date >=? and due_date <=?",contrast_time,Time.now)
puts issues
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
puts recipients
recipients.each do |r|
issue.forge_messages << ForgeMessage.new(:user_id => r.id, :project_id => issue.project_id, :viewed => false, :status => true)
issue.forge_messages << ForgeMessage.new(:user_id => r.id, :project_id => issue.project_id, :viewed => false, :status => 1)
# 发送邮件通知
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
end