diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e0726599b..c13334b08 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -83,13 +83,10 @@ 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}#{l(:label_day_mail)}" - date_from = "#{date_from} 17:59:59" date_to = "#{date_to} 17:59:59" - # 生成token用于直接点击登录 @user = user @token = Token.get_token_from_user(user, 'autologin') @@ -102,7 +99,7 @@ class Mailer < ActionMailer::Base # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷 sql = "select * from members m, issues i where i.project_id = m.project_id and m.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提交作业 @@ -125,7 +122,9 @@ class Mailer < ActionMailer::Base @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") # 查询user在课程。项目中发布的讨论帖子 - messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + messages = Message.find_by_sql("select me.* from messages me, boards b, members m where + b.id = me.board_id and b.project_id = m.project_id and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") @course_messages ||= [] @project_messages ||= [] unless messages.first.nil? diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 2cf070960..1ea977e89 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -193,6 +193,7 @@ <% end %> <% end %> + <% if @issues.first || @project_messages.first %>