@ -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 |