每日发送取日期不对

This commit is contained in:
guange 2015-04-01 17:47:04 +08:00
parent 0099ab9f9a
commit 9cefb9f339
2 changed files with 9 additions and 7 deletions

View File

@ -63,6 +63,12 @@ class Mailer < ActionMailer::Base
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
subject = "[ #{user.show_name} : #{l(:label_day_mail)}]"
@subject = " #{user.show_name} : #{date_to} #{l(:label_day_mail)}"
date_from = "#{date_from} 23:59:59"
date_to = "#{date_to} 23:59:59"
# 生成token用于直接点击登录
@user = user
token = Token.new(:user =>user , :action => 'autologin')
@ -77,10 +83,11 @@ class Mailer < ActionMailer::Base
course_ids = courses.map {|course| course.id}.join(",")
# 查询user的缺陷包括发布的跟踪的以及被指派的缺陷
@issues = Issue.find_by_sql("select DISTINCT i.* from issues i, watchers w
sql = "select DISTINCT i.* from issues i, watchers w
where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc")
and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
@issues = Issue.find_by_sql(sql)
# @bids 查询课程作业包括老师发布的作业以及user提交作业
# @attachments查询课程课件更新
@ -133,8 +140,6 @@ class Mailer < ActionMailer::Base
@memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
subject = "[ #{user.show_name} : #{l(:label_day_mail)}]"
@subject = " #{user.show_name} : #{date_to - 1.days} #{l(:label_day_mail)}"
has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news,
@course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o|

View File

@ -84,9 +84,6 @@ default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: smtp.126.com
port: 25
domain: smtp.126.com