Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Limit the number of shown WPs in the daily email

Henriette Darge2a69c19f6b6d
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb
index 02356bf4e80..bbf1691c812 100644
--- a/app/helpers/mail_digest_helper.rb
+++ b/app/helpers/mail_digest_helper.rb
@@ -76,11 +76,11 @@ module MailDigestHelper
if extended
raw(I18n.t(:"mail.digests.work_packages.#{value}") +
' ' +
- I18n.t(:"mail.digests.work_packages.#{value}",
+ I18n.t(:"mail.digests.work_packages.#{value}_at",
user: user,
timestamp: time_ago_in_words(journal.created_at)))
else
- raw(I18n.t(:"mail.digests.work_packages.#{value}",
+ raw(I18n.t(:"mail.digests.work_packages.#{value}_at",
user: user,
timestamp: time_ago_in_words(journal.created_at)))
end
diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb
index 8064f237369..7a585f94522 100644
--- a/app/mailers/digest_mailer.rb
+++ b/app/mailers/digest_mailer.rb
@@ -39,6 +39,8 @@ class DigestMailer < ApplicationMailer
helper :mail_digest
+ MAX_SHOWN_WORK_PACKAGES = 15.freeze
+
class << self
def generate_message_id(_, user)
hash = "openproject.digest-#{user.id}-#{Time.current.strftime('%Y%m%d%H%M%S')}"
diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erb
index 85b95cbbc4e..2594dbb5ae7 100644
--- a/app/views/digest_mailer/work_packages.html.erb
+++ b/app/views/digest_mailer/work_packages.html.erb
@@ -20,7 +20,7 @@
</tr>
</table>
-<% @aggregated_notifications.each do | work_package, notifications_by_work_package| %>
+<% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>
<a style="border: 1px solid #E0E0E0;
margin-bottom: 15px;
padding: 12px;
@@ -93,7 +93,23 @@
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin: 30px 0;">
<tr>
- <td width="100%"></td>
+ <td width="100%">
+ <% if @aggregated_notifications.length > DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
+ <span>
+ <% number_of_overflowing_work_packages = @aggregated_notifications.length - DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
+ <% if number_of_overflowing_work_packages === 1 %>
+ <%= I18n.t(:'mail.digests.work_packages.more_to_see_singular') %>
+ <% else %>
+ <%= I18n.t(:'mail.digests.work_packages.more_to_see_plural', number: number_of_overflowing_work_packages) %>
+ <% end %>
+ </span>
+ <a
+ target="_blank"
+ style="background-color: #D1E5F5; padding: 8px 12px; color: #1A67A3; border: 1px solid #1A67A3; border-radius: 16px; text-decoration: none; white-space: nowrap;">
+ <%= I18n.t(:'mail.digests.work_packages.see_all') %>
+ </a>
+ <% end %>
+ </td>
<td>
<a href="<%= my_notifications_url %>"
target="_blank"
diff --git a/app/views/digest_mailer/work_packages.text.erb b/app/views/digest_mailer/work_packages.text.erb
index c80ea98ec9a..e6388d20582 100644
--- a/app/views/digest_mailer/work_packages.text.erb
+++ b/app/views/digest_mailer/work_packages.text.erb
@@ -1,4 +1,4 @@
-<% @aggregated_notifications.each do | work_package, notifications_by_work_package| %>
+<% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>
<%= "=" * (('# ' + work_package.id.to_s + work_package.subject).length + 4) %>
= #<%= work_package.id %> <%= work_package.subject %> =
@@ -7,11 +7,11 @@
<% notifications_by_work_package.each do | notification | %>
<%= "-" * 20 %>
+ <% unique_reasons = unique_reasons_of_notifications(notifications_by_work_package) %>
<%= digest_notification_timestamp_text(
notification,
html: false,
- extended_text: true) %> (<%= I18n.t('mail.digests.work_packages.reason.prefix',
- reason: I18n.t(:"mail.digests.work_packages.reason.#{notification.reason_mail_digest}")) %>)
+ extended_text: true) %> (<% unique_reasons.each_with_index do |reason, index| %><%= I18n.t(:"mail.digests.work_packages.reason.#{reason || :unknown}", default: '-') %><%= ', ' unless unique_reasons.size-1 == index %><% end %>)
<% journal = notification.journal %>
<% if journal.notes.present? %>
@@ -25,3 +25,14 @@
<%= "-" * 20 %>
<% end %>
<% end %>
+
+<%= "-" * 100 %>
+
+<% if @aggregated_notifications.length > DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
+<% number_of_overflowing_work_packages = @aggregated_notifications.length - DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
+<% if number_of_overflowing_work_packages === 1 %>
+<%= I18n.t(:'mail.digests.work_packages.more_to_see_singular') %> <%= I18n.t(:'mail.digests.work_packages.login_to_see_all') %>
+<% else %>
+<%= I18n.t(:'mail.digests.work_packages.more_to_see_plural', number: number_of_overflowing_work_packages) %> <%= I18n.t(:'mail.digests.work_packages.login_to_see_all') %>
+<% end %>
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 701fc7e0b93..7baca0c65c2 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1974,12 +1974,16 @@ en:
work_packages:
created: 'Created'
created_at: 'by %{user} %{timestamp} ago'
+ login_to_see_all: 'Log in to see all notifications.'
+ more_to_see_singular: 'There is 1 more work package with notifications.'
+ more_to_see_plural: 'There are %{number} more work packages with notifications.'
reason:
watched: 'watched'
involved: 'assignee or responsible'
mentioned: 'mentioned'
subscribed: 'all'
prefix: 'Received because of the notification setting: %{reason}'
+ see_all: 'See all'
subject: 'Daily project summary for %{date} - %{number} updates'
updated: 'Updated'
updated_at: '%{timestamp} ago by %{user}'