diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-04 23:36:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-04 23:36:47 +0000 |
commit | 0a92e382fa18325a633a73b3f5f13fa831d4e016 (patch) | |
tree | cbb7bcc0c805cf0c1b3900d8504c4e2b593e2a69 | |
parent | b9e02477e90245756d6e5ba1b2da5910bc13ccd7 (diff) | |
download | redmine-0a92e382fa18325a633a73b3f5f13fa831d4e016.tar.gz redmine-0a92e382fa18325a633a73b3f5f13fa831d4e016.zip |
Use scopes instead of ARCondition.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8087 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/mailer.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 6f68918a9..1e3995724 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -343,16 +343,15 @@ class Mailer < ActionMailer::Base tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil user_ids = options[:users] - s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date] - s << "#{Issue.table_name}.assigned_to_id IS NOT NULL" - s << ["#{Issue.table_name}.assigned_to_id IN (?)", user_ids] if user_ids.present? - s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" - s << "#{Issue.table_name}.project_id = #{project.id}" if project - s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker - - issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker], - :conditions => s.conditions - ).group_by(&:assigned_to) + scope = Issue.scoped(:conditions => ["#{Issue.table_name}.assigned_to_id IS NOT NULL" + + " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date] + ) + scope = scope.scoped(:conditions => {:assigned_to_id => user_ids}) if user_ids.present? + scope = scope.scoped(:conditions => {:project_id => project.id}) if project + scope = scope.scoped(:conditions => {:tracker_id => tracker.id}) if tracker + + issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to) issues_by_assignee.each do |assignee, issues| deliver_reminder(assignee, issues, days) if assignee && assignee.active? end |