Feature #29771

Sort issues by due date in email reminders

Added by Go MAEDA about 1 month ago. Updated 11 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Email notifications
Target version:4.0.0
Resolution:Fixed

Description

Currently, it seems that issues in email reminders are not sorted, or sorted in a less meaningful order for humans.

I think it is useful for most users to sort issues by the due date in descending order (overdue issues are shown first).

29771-reminders-order-due-date.patch Magnifier (2.64 KB) Yuichi HARADA, 2018-10-17 08:35

29771-v2.patch Magnifier - slightly updated the test code (1.8 KB) Go MAEDA, 2018-11-04 02:26

29771-v3.patch Magnifier - due_date in ascending order (2.78 KB) Yuichi HARADA, 2018-11-05 04:15


Related issues

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

Associated revisions

Revision 17624
Added by Go MAEDA 11 days ago

Sort issues by due date in email reminders (#29771).

Patch by Yuichi HARADA.

History

#1 Updated by Go MAEDA about 1 month ago

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

#2 Updated by Yuichi HARADA about 1 month ago

Currently, the order of arrangement depends on the DBMS. (In no order)

Go MAEDA wrote:

I think it is useful for most users to sort issues by the due date in descending order (overdue issues are shown first).

I made a patch, and attach it.

diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 468e6c21a..800fdde88 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -27,7 +27,7 @@ class Mailer < ActionMailer::Base
   include Roadie::Rails::Automatic

   # Overrides ActionMailer::Base#process in order to set the recipient as the current user
-  # and his language as the default locale. 
+  # and his language as the default locale.
   # The first argument of all actions of this Mailer must be a User (the recipient),
   # otherwise an ArgumentError is raised.
   def process(action, *args)
@@ -584,6 +584,7 @@ class Mailer < ActionMailer::Base
     issues_by_assignee.each do |assignee, issues|
       if assignee.is_a?(User) && assignee.active? && issues.present?
         visible_issues = issues.select {|i| i.visible?(assignee)}
+        visible_issues.sort!{|a, b| (b.due_date <=> a.due_date).nonzero? || (a.id <=> b.id)}
         reminder(assignee, visible_issues, days).deliver_later if visible_issues.present?
       end
     end

#3 Updated by Go MAEDA 27 days ago

  • Target version set to Candidate for next major release

#4 Updated by Go MAEDA 13 days ago

  • File 29771-v2.patchMagnifier added
  • Target version changed from Candidate for next major release to 4.1.0

Thank you for posting the patch. The patch works fine for me.

I slightly updated the test code in Yuichi HARADA's patch to make it even easier to read. Attaching the new patch.

#5 Updated by Yuichi HARADA 12 days ago

Go MAEDA wrote:

I slightly updated the test code in Yuichi HARADA's patch to make it even easier to read. Attaching the new patch.

It is easy to understand using assert_select.

#6 Updated by Yuichi HARADA 12 days ago

Yuichi HARADA wrote:

Go MAEDA wrote:

I slightly updated the test code in Yuichi HARADA's patch to make it even easier to read. Attaching the new patch.

It is easy to understand using assert_select.

I'm sorry.
The new patch was not attach.

I changed due_date in ascending order, because overdue issues are shown first.
I rebuilt a patch, and attach it.

#7 Updated by Go MAEDA 11 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.0 to 4.0.0
  • Resolution set to Fixed

Committed. Thank you for improving Redmine.

Also available in: Atom PDF