增加定时任务
This commit is contained in:
parent
ec41054008
commit
6d5f72326f
|
@ -165,6 +165,31 @@ class Mailer < ActionMailer::Base
|
||||||
:subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
|
:subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#缺陷到期邮件通知
|
||||||
|
def issue_expire issue
|
||||||
|
#@issues = issues
|
||||||
|
#s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
|
||||||
|
#puts s + "////" + issue.assigned_to.mail
|
||||||
|
#@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id)
|
||||||
|
#mail :to => issue.assigned_to.mail,
|
||||||
|
# :subject => s
|
||||||
|
issue_id = issue.project_index
|
||||||
|
redmine_headers 'Project' => issue.project.identifier,
|
||||||
|
'Issue-Id' => issue_id,
|
||||||
|
'Issue-Author' => issue.author.login
|
||||||
|
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||||
|
message_id issue
|
||||||
|
@author = issue.author
|
||||||
|
@issue = issue
|
||||||
|
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||||
|
recipients = issue.recipients
|
||||||
|
cc = issue.watcher_recipients - recipients
|
||||||
|
mail :to => recipients,
|
||||||
|
:cc => cc,
|
||||||
|
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Builds a Mail::Message object used to email users belonging to the added document's project.
|
# Builds a Mail::Message object used to email users belonging to the added document's project.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -541,6 +566,35 @@ class Mailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#缺陷到期后发送邮件提示
|
||||||
|
def mail_issue
|
||||||
|
threads = []
|
||||||
|
issues = Issue.where("done_ratio <> 100 && closed_on is null && due_date is not null")
|
||||||
|
issues.each do |issue|
|
||||||
|
thread = Thread.start do
|
||||||
|
while true
|
||||||
|
cur_issue = Issue.find issue.id
|
||||||
|
if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if Time.now < Time.parse(cur_issue.due_date.to_s)
|
||||||
|
#休眠一个小时。。。
|
||||||
|
sleep 3600
|
||||||
|
else
|
||||||
|
#发邮件
|
||||||
|
puts issue.id.to_s
|
||||||
|
Mailer.issue_expire(issue).deliver
|
||||||
|
#Mailer.issue_add(issue).deliver
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
threads << thread
|
||||||
|
end
|
||||||
|
puts threads.count.to_s
|
||||||
|
threads
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Appends a Redmine header field (name is prepended with 'X-Redmine-')
|
# Appends a Redmine header field (name is prepended with 'X-Redmine-')
|
||||||
|
@ -571,4 +625,6 @@ class Mailer < ActionMailer::Base
|
||||||
def mylogger
|
def mylogger
|
||||||
Rails.logger
|
Rails.logger
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#Mailer.mail_issue.each do |t|
|
||||||
|
# t.join
|
||||||
|
#end
|
||||||
|
|
|
@ -1134,6 +1134,7 @@ zh:
|
||||||
text_zoom_in: 放大
|
text_zoom_in: 放大
|
||||||
text_zoom_out: 缩小
|
text_zoom_out: 缩小
|
||||||
text_applied_project: "用户 %{id} 申请加入项目 %{project}"
|
text_applied_project: "用户 %{id} 申请加入项目 %{project}"
|
||||||
|
text_issue_expire: "分配给您的任务%{issue}即将到期"
|
||||||
|
|
||||||
default_role_manager: 管理人员
|
default_role_manager: 管理人员
|
||||||
default_role_developer: 开发人员
|
default_role_developer: 开发人员
|
||||||
|
|
Loading…
Reference in New Issue