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|