Project

General

Profile

Actions

Feature #23778

closed

default sort email reminders by due date (and list due date in email)

Added by John Simmons over 7 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate

Description

I think this should be default behavior. I've already written the code to do this, but I'm not sure how to get the code to you since the [contribute](http://www.redmine.org/projects/redmine/wiki/Contribute) page says not to use pull requests. What is the preferred method of getting the code to you on github? I see the link to creating patches on git, but I didn't really follow it. Can someone give me a more detailed explanation?

I uploaded a file of what our email reminders look like now after the changes.


Files

redmineReminderEdited.png (71 KB) redmineReminderEdited.png John Simmons, 2016-09-07 17:09
emailSortByDate.patch (1.67 KB) emailSortByDate.patch John Simmons, 2016-09-07 23:20

Related issues

Related to Redmine - Patch #6357: Show and sort by due_date in remindersClosed2010-09-10

Actions
Related to Redmine - Feature #31225: Show the number of days left until the due date in remindersClosedGo MAEDA

Actions
Actions #1

Updated by Moritz Koehler over 7 years ago

would you mind to share the code here for now. Looks very good.

Actions #2

Updated by John Simmons over 7 years ago

In app/helpers/application_helper.rb, in the link_to_issue function

  def link_to_issue(issue, options={})
    title = nil
    subject = nil
    text = options[:tracker] == false ? "##{issue.id}" : "#{issue.tracker} ##{issue.id}" 
    if options[:subject] == false
      title = issue.subject.truncate(60)
    else
      subject = issue.subject
      if truncate_length = options[:truncate]
        subject = subject.truncate(truncate_length)
      end
    end
    only_path = options[:only_path].nil? ? true : options[:only_path]
    s = link_to(text, issue_url(issue, :only_path => only_path),
                :class => issue.css_classes, :title => title)
    s << h(": #{subject}") if subject
    #This is the only line that changes here
    s = h("Due date #{issue.due_date} : #{issue.project} - ") + s if options[:project]
    s
  end

The other change is in app/models/mailer.rb, in the reminders function

  def self.reminders(options={})
    days = options[:days] || 7
    project = options[:project] ? Project.find(options[:project]) : nil
    tracker = options[:tracker] ? Tracker.find(options[:tracker]) : 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 with named #{options[:version]}")
    end
    user_ids = options[:users]
    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(: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
    issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
                              group_by(&:assigned_to)
    issues_by_assignee.keys.each do |assignee|
      if assignee.is_a?(Group)
        assignee.users.each do |user|
          issues_by_assignee[user] ||= []
          issues_by_assignee[user] += issues_by_assignee[assignee]
        end
      end
    end
    issues_by_assignee.each do |assignee, issues|
      #My changes start here
      issues = issues.sort_by do |item|
        item[:due_date]
      end
      #End of changes
      reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
    end
  end

I commented where the changes are.

Actions #3

Updated by John Simmons over 7 years ago

It's barely anything, which is why I was a little shocked that it wasn't already sorted. But if accepted it will be my first contribution to redmine....so yay!

Also, this hasn't been fully tested. I've run it against everything I have right now, but I haven't run it through any official testing...so take it for what it's worth right now.

Actions #4

Updated by Marius BÄ‚LTEANU over 7 years ago

It'll be better to provide a patch. Check How_to_create_patch_series_on_Mercurial_and_Git or use the command git diff > path_to_patch

Actions #5

Updated by John Simmons over 7 years ago

Here's the patch. If I'm supposed to put it somewhere else please let me know. Also, I won't have a chance to really test it for a few days probably, so if you see any errors please let me know.

Actions #6

Updated by Toshi MARUYAMA over 7 years ago

"link_to_issue" is used at many places.
So,

    s = h("Due date #{issue.due_date} : #{issue.project} - ") + s if options[:project]

breaks many places.

Actions #7

Updated by Go MAEDA over 5 years ago

  • Related to Patch #6357: Show and sort by due_date in reminders added
Actions #8

Updated by Go MAEDA over 5 years ago

Issues in reminders are now sorted by due date (#29771).

Actions #9

Updated by Go MAEDA almost 5 years ago

  • Related to Feature #31225: Show the number of days left until the due date in reminders added
Actions #10

Updated by Go MAEDA almost 5 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

The upcoming Redmine 4.1.0 shows the number of days left until the due date ("due in X days" / "X days late"). Please see #31225 for details.

Actions

Also available in: Atom PDF