Feature #28638 » mailer.rb.patch
| app/models/mailer.rb | ||
|---|---|---|
|
# Available options:
|
||
|
# * :days => how many days in the future to remind about (defaults to 7)
|
||
|
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
||
|
# * :statuses => comma separated list of issue_statuses ids (defaults to all issue_statuses)
|
||
|
# * :project => id or identifier of project to process (defaults to all projects)
|
||
|
# * :users => array of user/group ids who should be reminded
|
||
|
# * :version => name of target version for filtering issues (defaults to none)
|
||
| ... | ... | |
|
days = options[:days] || 7
|
||
|
project = options[:project] ? Project.find(options[:project]) : nil
|
||
|
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||
|
status = options[:status] ? IssueStatus.find(options[:status]) : nil
|
||
|
target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil
|
||
|
if options[:version] && target_version_id.blank?
|
||
|
raise ActiveRecord::RecordNotFound.new("Couldn't find Version named #{options[:version]}")
|
||
|
end
|
||
|
user_ids = options[:users]
|
||
|
issue_statuses_ids = options[:statuses]
|
||
|
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
|
||
|
)
|
||
|
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
|
||
|
scope = scope.where(:status_id => issue_statuses_ids) if issue_statuses_ids.present?
|
||
|
scope = scope.where(:project_id => project.id) if project
|
||
|
scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present?
|
||
|
scope = scope.where(:tracker_id => tracker.id) if tracker
|
||