@ -120,17 +120,17 @@ class Mailer < ActionMailer::Base
count=courses.count
count=count-1
foriin0..countdo
bids=courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
attachments=courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
bids=courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order(" '#{courses[i].id}', homework_commons.created_at desc")
attachments=courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order(" '#{courses[i].id}',attachments.created_on DESC' ")
@bids+=bidsifbids.count>0
@attachments+=attachmentsifattachments.count>0
end
@bids.sort{|a,b|a.created_at<=>b.created_at}
# @bids = @bids.sort_by { |obj| obj.created_at }
end
# 项目附件
@project_attachments=Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a
# 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||=[]
@ -168,31 +168,31 @@ class Mailer < ActionMailer::Base
# 查询user在课程中发布的通知和回复通知
@course_news=(course_ids&&!course_ids.empty?)?News.find_by_sql("select DISTINCT n.* from news n
@user_journal_messages=user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
# 查询user在项目中留言(用户反馈)
@project_journal_messages=JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p
@forums=Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")