Project

General

Profile

Actions

Feature #8342

open

Enhance reminder email to send all assigned issues

Added by Mathew C over 13 years ago. Updated over 11 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
2011-05-11
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Currently the reminder email requires that issues have a due date to send the reminder email. It might also be useful to have a reminder email for overdue issues.

To implement, this, I'd like to propose adding the following code. I did consider modifying the reminder function, but I was concerned about not changing current functionality and impacts on localisation.

File: lib/tasks/reminder.rake

  task :send_reminders_assigned => :environment do
    options = {}
    options[:project] = ENV['project'] if ENV['project']
    options[:tracker] = ENV['tracker'].to_i if ENV['tracker']
    options[:users] = (ENV['users'] || '').split(',').each(&:strip!)

    Mailer.reminders_assigned(options)
  end

File: app/models/mailer.rb

  def reminder_assigned(user, issues)
    set_language_if_valid user.language
    recipients user.mail
    subject l(:mail_subject_reminder_assigned, :count => issues.size)
    body :issues => issues,
         :issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.\
id, :sort => 'due_date:asc')
    render_multipart('reminder_assigned', body)
  end

  # Sends reminders to issue assignees
  # Available options:
  # * :tracker  => id of tracker for filtering issues (defaults to all trackers)
  # * :project  => id or identifier of project to process (defaults to all projects)
  # * :users    => array of user ids who should be reminded
  def self.reminders_assigned(options={})
    project = options[:project] ? Project.find(options[:project]) : nil
    tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
    user_ids = options[:users]

    s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ?", false]
    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)
    issues_by_assignee.each do |assignee, issues|
      deliver_reminder_assigned(assignee, issues) if assignee && assignee.active?
    end
  end

In addition to the above, the following changes are required:
  • new file: app/views/mailer/reminder_assigned.text.html.rhtml
  • new file: app/views/mailer/reminder_assigned.text.plain.rhtml
  • new localisation: mail_subject_reminder_assigned
  • new localisation: mail_body_reminder_assigned

I can create a patch of these changes if helpful.


Related issues

Related to Redmine - Feature #415: Daily Digest option for Mail NotificationsNew

Actions
Actions

Also available in: Atom PDF