@@ -343,16 +343,15 class Mailer < ActionMailer::Base | |||||
343 | tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil |
|
343 | tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil | |
344 | user_ids = options[:users] |
|
344 | user_ids = options[:users] | |
345 |
|
345 | |||
346 | s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date] |
|
346 | scope = Issue.scoped(:conditions => ["#{Issue.table_name}.assigned_to_id IS NOT NULL" + | |
347 | s << "#{Issue.table_name}.assigned_to_id IS NOT NULL" |
|
347 | " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + | |
348 | s << ["#{Issue.table_name}.assigned_to_id IN (?)", user_ids] if user_ids.present? |
|
348 | " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date] | |
349 | s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" |
|
349 | ) | |
350 | s << "#{Issue.table_name}.project_id = #{project.id}" if project |
|
350 | scope = scope.scoped(:conditions => {:assigned_to_id => user_ids}) if user_ids.present? | |
351 | s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker |
|
351 | scope = scope.scoped(:conditions => {:project_id => project.id}) if project | |
352 |
|
352 | scope = scope.scoped(:conditions => {:tracker_id => tracker.id}) if tracker | ||
353 | issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker], |
|
353 | ||
354 | :conditions => s.conditions |
|
354 | issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to) | |
355 | ).group_by(&:assigned_to) |
|
|||
356 | issues_by_assignee.each do |assignee, issues| |
|
355 | issues_by_assignee.each do |assignee, issues| | |
357 | deliver_reminder(assignee, issues, days) if assignee && assignee.active? |
|
356 | deliver_reminder(assignee, issues, days) if assignee && assignee.active? | |
358 | end |
|
357 | end |
General Comments 0
You need to be logged in to leave comments.
Login now