From: Jean-Philippe Lang Date: Sun, 9 Sep 2012 11:34:35 +0000 (+0000) Subject: Code cleanup. X-Git-Tag: 2.1.0~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=972a991a922e1dfe0de7474ec727e97408cf9dcc;p=redmine.git Code cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10337 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/mailer.rb b/app/models/mailer.rb index b8b2ac721..65ca9ea08 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -334,15 +334,15 @@ class Mailer < ActionMailer::Base tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil user_ids = options[:users] - scope = Issue.open.scoped(:conditions => ["#{Issue.table_name}.assigned_to_id IS NOT NULL" + + scope = Issue.open.where("#{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] + " 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 + scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? + scope = scope.where(:project_id => project.id) if project + scope = scope.where(:tracker_id => tracker.id) if tracker - issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to) + issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).all.group_by(&:assigned_to) issues_by_assignee.keys.each do |assignee| if assignee.is_a?(Group) assignee.users.each do |user|