From 79f52956910d8e17cda768bdc44df7aa9ad06f2d Mon Sep 17 00:00:00 2001 From: bilel Date: Sat, 24 Jun 2017 11:16:42 +0100 Subject: [PATCH 1/9] add ability to send reminder for task which dont have due date set --- .../reminder_configuration_controller.rb | 2 +- app/models/reminder_all_mailer.rb | 9 +++-- app/models/reminder_configuration.rb | 1 + .../reminder_all_mailer/reminder_all.html.erb | 4 ++ .../reminder_all_mailer/reminder_all.text.erb | 4 ++ .../reminder_configuration/edit.html.erb | 4 ++ config/locales/en.yml | 2 + ...d_use_due_day_to_reminder_configuration.rb | 5 +++ lib/redmine_reminder/collector.rb | 39 ++++++++++++++----- lib/tasks/reminder_all.rake | 1 + 10 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb diff --git a/app/controllers/reminder_configuration_controller.rb b/app/controllers/reminder_configuration_controller.rb index ab289b0..a411f03 100644 --- a/app/controllers/reminder_configuration_controller.rb +++ b/app/controllers/reminder_configuration_controller.rb @@ -23,7 +23,7 @@ def update def permitted_conf_params params.required(:reminder_configuration).permit( :days, :issue_status_selector, :project_selector, :tracker_selector, :send_to_author, - :send_to_assigned_to, :send_to_watcher, :send_to_custom_user, + :send_to_assigned_to, :use_due_day, :send_to_watcher, :send_to_custom_user, { issue_status_ids: [] }, { project_ids: [] }, { tracker_ids: [] } diff --git a/app/models/reminder_all_mailer.rb b/app/models/reminder_all_mailer.rb index 7572c49..75c390a 100644 --- a/app/models/reminder_all_mailer.rb +++ b/app/models/reminder_all_mailer.rb @@ -1,7 +1,7 @@ class ReminderAllMailer < Mailer helper :reminder_all - def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, days) + def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, without_due_day, days) recipients = user.mail day_tag = [l(:mail_reminder_all_day1), l(:mail_reminder_all_day2), l(:mail_reminder_all_day2), l(:mail_reminder_all_day2), @@ -25,6 +25,7 @@ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user @auth_issues = auth_issues @watched_issues = watched_issues @custom_user_issues = custom_user_issues + @without_due_day = without_due_day @days = days @issues_url = url_for( controller: 'issues', @@ -35,9 +36,9 @@ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user mail to: recipients, subject: subject end - def self.deliver_reminder_all_if_any(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, days) - issues_count = (assigned_issues + auth_issues + watched_issues + custom_user_issues).uniq.size + def self.deliver_reminder_all_if_any(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, without_due_day, days) + issues_count = (assigned_issues + auth_issues + watched_issues + custom_user_issues + without_due_day).uniq.size reminder_all(user, assigned_issues, auth_issues, watched_issues, - custom_user_issues, days).deliver if issues_count > 0 + custom_user_issues, without_due_day, days).deliver if issues_count > 0 end end diff --git a/app/models/reminder_configuration.rb b/app/models/reminder_configuration.rb index 2665d62..72274c4 100644 --- a/app/models/reminder_configuration.rb +++ b/app/models/reminder_configuration.rb @@ -53,6 +53,7 @@ def set_default_values self.send_to_assigned_to = true if self.send_to_assigned_to.nil? self.send_to_watcher = true if self.send_to_watcher.nil? self.send_to_custom_user ||= false + self.use_due_day ||= false true end end diff --git a/app/views/reminder_all_mailer/reminder_all.html.erb b/app/views/reminder_all_mailer/reminder_all.html.erb index c27851b..fe2a2fb 100644 --- a/app/views/reminder_all_mailer/reminder_all.html.erb +++ b/app/views/reminder_all_mailer/reminder_all.html.erb @@ -14,4 +14,8 @@ issues: @custom_user_issues, message: l_mail_body_reminder_custom_user(@custom_user_issues.size, @days) } %> +<%= render partial: 'issues', locals: { + issues: @without_due_day, + message: l(:mail_body_reminder_assigned_set, @assigned_issues.size) } %> +

<%= link_to l(:label_issue_view_all), @issues_url %>

diff --git a/app/views/reminder_all_mailer/reminder_all.text.erb b/app/views/reminder_all_mailer/reminder_all.text.erb index c06f6d4..73a4000 100644 --- a/app/views/reminder_all_mailer/reminder_all.text.erb +++ b/app/views/reminder_all_mailer/reminder_all.text.erb @@ -14,4 +14,8 @@ issues: @custom_user_issues, message: l_mail_body_reminder_custom_user(@custom_user_issues.size, @days) } %> +<%= render partial: 'issues', locals: { + issues: @without_due_day, + message: l(:mail_body_reminder_assigned_set, @custom_user_issues.size) } %> + <%= @issues_url %> diff --git a/app/views/reminder_configuration/edit.html.erb b/app/views/reminder_configuration/edit.html.erb index 38524bd..88ef213 100644 --- a/app/views/reminder_configuration/edit.html.erb +++ b/app/views/reminder_configuration/edit.html.erb @@ -39,6 +39,10 @@ <%= f.check_box :send_to_author %> <%= f.label :send_to_author, l(:field_author) %> +
+ + <%= f.check_box :use_due_day %> + <%= f.label :use_due_day, l(:field_use_due_day) %>
<%= f.check_box :send_to_assigned_to %> diff --git a/config/locales/en.yml b/config/locales/en.yml index fc063c2..1a53d18 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,6 +17,7 @@ en: mail_body_reminder_assigned5: "%{count} issues that are assigned to you are due in the next %{days} %{day}:" mail_body_reminder_watched5: "%{count} issues that are watched by you are due in the next %{days} %{day}:" mail_body_reminder_custom_user5: "%{count} issues in which you are mentioned are due in the next %{days} %{day}:" + mail_body_reminder_assigned_set: "%{count} issues that are assigned to you which don't have end date set:" label_reminder_options: "Reminder options" label_criteria_task: "Criteria task" @@ -37,3 +38,4 @@ en: explicit: "tasks from selected trackers" field_custom_user: "User from custom field" + field_use_due_day: "Send tasks which have end date only" diff --git a/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb new file mode 100644 index 0000000..3e09fac --- /dev/null +++ b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb @@ -0,0 +1,5 @@ +class AddUseDueDayToReminderConfiguration < ActiveRecord::Migration + def change + add_column :reminder_configurations, :use_due_day, :boolean, default: false + end +end diff --git a/lib/redmine_reminder/collector.rb b/lib/redmine_reminder/collector.rb index 90ed49c..6c0873d 100644 --- a/lib/redmine_reminder/collector.rb +++ b/lib/redmine_reminder/collector.rb @@ -8,25 +8,30 @@ def initialize(options) def collect_reminders reminders = {} - issues = issues_due_in_days + issues = if options.use_due_day? + issues_due_in_days(true) + else + issues_due_in_days(false) + end + issues.each do |issue| if options.send_to_author? reminders[issue.author] ||= - RedmineReminder::Reminder.new(issue.author) + RedmineReminder::Reminder.new(issue.author) reminders[issue.author][:author] << issue end if options.send_to_assigned_to? && issue.assigned_to reminders[issue.assigned_to] ||= - RedmineReminder::Reminder.new(issue.assigned_to) + RedmineReminder::Reminder.new(issue.assigned_to) reminders[issue.assigned_to][:assigned_to] << issue end if options.send_to_watcher? issue.watchers.each do |watcher| reminders[watcher.user] ||= - RedmineReminder::Reminder.new(watcher.user) + RedmineReminder::Reminder.new(watcher.user) reminders[watcher.user][:watcher] << issue end end @@ -34,10 +39,15 @@ def collect_reminders if options.send_to_custom_user? issue_custom_users(issue).each do |custom_user| reminders[custom_user] ||= - RedmineReminder::Reminder.new(custom_user) + RedmineReminder::Reminder.new(custom_user) reminders[custom_user][:custom_user] << issue end end + + reminders[issue.assigned_to] ||= RedmineReminder::Reminder.new(issue.assigned_to) + unless options.use_due_day? + reminders[issue.assigned_to][:without_due_day] << issue unless issue.due_date + end end reminders.values.map &:uniq! reminders.values || [] @@ -46,15 +56,24 @@ def collect_reminders private # Get issues due in X days - def issues_due_in_days + def issues_due_in_days(use_due_day = true) due_date = options.days.day.from_now.to_date - sql_condition = ARCondition.new ["#{Issue.table_name}.due_date <= ?", due_date] + sql_condition = if use_due_day + ARCondition.new ["#{Issue.table_name}.due_date <= ?", due_date] + else + ARCondition.new ["#{Issue.table_name}.due_date <= ? OR #{Issue.table_name}.due_date IS NULL", due_date] + end + sql_condition << issue_statuses sql_condition << projects sql_condition << trackers - Issue.joins(:status, :assigned_to, :author, :project, :watchers, :tracker). - where(sql_condition.conditions). - order("#{Issue.table_name}.due_date, #{Project.table_name}.name") + scope = Issue.includes(:status, :assigned_to, :author, :project, :watchers, :tracker) + if Redmine::VERSION::MAJOR>=3 + scope = scope.references(:status, :assigned_to, :author, :project, :watchers, :tracker) + end + + scope.where(sql_condition.conditions). + order("#{Issue.table_name}.due_date, #{Project.table_name}.name") end def issue_statuses diff --git a/lib/tasks/reminder_all.rake b/lib/tasks/reminder_all.rake index d5fe745..a261f57 100644 --- a/lib/tasks/reminder_all.rake +++ b/lib/tasks/reminder_all.rake @@ -38,6 +38,7 @@ namespace :redmine do r[:author], r[:watcher], r[:custom_user], + r[:without_due_day], options.days ) end From ed075f5808bbb0cd17ebe13481f912b72af4386b Mon Sep 17 00:00:00 2001 From: royyeh22 Date: Fri, 28 Jul 2017 14:48:34 +0800 Subject: [PATCH 2/9] Add files via upload --- app/views/reminder_all_mailer/reminder_all.html.erb | 2 +- app/views/reminder_all_mailer/reminder_all.text.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/reminder_all_mailer/reminder_all.html.erb b/app/views/reminder_all_mailer/reminder_all.html.erb index fe2a2fb..6b66162 100644 --- a/app/views/reminder_all_mailer/reminder_all.html.erb +++ b/app/views/reminder_all_mailer/reminder_all.html.erb @@ -16,6 +16,6 @@ <%= render partial: 'issues', locals: { issues: @without_due_day, - message: l(:mail_body_reminder_assigned_set, @assigned_issues.size) } %> + message: l(:mail_body_reminder_assigned_set, @without_due_day.size) } %>

<%= link_to l(:label_issue_view_all), @issues_url %>

diff --git a/app/views/reminder_all_mailer/reminder_all.text.erb b/app/views/reminder_all_mailer/reminder_all.text.erb index 73a4000..deb3e6b 100644 --- a/app/views/reminder_all_mailer/reminder_all.text.erb +++ b/app/views/reminder_all_mailer/reminder_all.text.erb @@ -16,6 +16,6 @@ <%= render partial: 'issues', locals: { issues: @without_due_day, - message: l(:mail_body_reminder_assigned_set, @custom_user_issues.size) } %> + message: l(:mail_body_reminder_assigned_set, @without_due_day.size) } %> <%= @issues_url %> From 4d7a482db9ddd270aff734558b2308d9ec0cae11 Mon Sep 17 00:00:00 2001 From: royyeh22 Date: Fri, 28 Jul 2017 14:56:41 +0800 Subject: [PATCH 3/9] avoid nil r.user for no-assignee issues witout-due issue should check assignee first, and issue list shall contain the one which has no due. --- lib/redmine_reminder/collector.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/redmine_reminder/collector.rb b/lib/redmine_reminder/collector.rb index 6c0873d..9960bda 100644 --- a/lib/redmine_reminder/collector.rb +++ b/lib/redmine_reminder/collector.rb @@ -5,6 +5,10 @@ def initialize(options) @options = options end + def logger + Rails.logger + end + def collect_reminders reminders = {} @@ -14,8 +18,8 @@ def collect_reminders issues_due_in_days(false) end + # logger.info issues.count() issues.each do |issue| - if options.send_to_author? reminders[issue.author] ||= RedmineReminder::Reminder.new(issue.author) @@ -26,6 +30,10 @@ def collect_reminders reminders[issue.assigned_to] ||= RedmineReminder::Reminder.new(issue.assigned_to) reminders[issue.assigned_to][:assigned_to] << issue + #logger.info "v=#{issue}" + #logger.info "v.author=#{issue.author}" + #logger.info "v.assigned_to=#{issue.assigned_to}" + #logger.info "v.due_date=#{issue.due_date}" end if options.send_to_watcher? @@ -44,13 +52,24 @@ def collect_reminders end end - reminders[issue.assigned_to] ||= RedmineReminder::Reminder.new(issue.assigned_to) - unless options.use_due_day? - reminders[issue.assigned_to][:without_due_day] << issue unless issue.due_date + if !options.use_due_day? && issue.assigned_to && !issue.due_date + #logger.info "v=#{issue}" + #logger.info "v.author=#{issue.author}" + #logger.info "v.assigned_to=#{issue.assigned_to}" + #logger.info "v.due_date=#{issue.due_date}" + reminders[issue.assigned_to] ||= + RedmineReminder::Reminder.new(issue.assigned_to) + reminders[issue.assigned_to][:without_due_day] << issue end end reminders.values.map &:uniq! reminders.values || [] + + #reminders.values.each do |v| + # logger.info "v=#{v}" + # logger.info "v.user=#{v.user}" + #end + end private From 87495ab102f048f28ad2d0a16c198ff08fd76c8b Mon Sep 17 00:00:00 2001 From: royyeh22 Date: Fri, 28 Jul 2017 15:51:32 +0800 Subject: [PATCH 4/9] Add files via upload --- lib/redmine_reminder/collector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/redmine_reminder/collector.rb b/lib/redmine_reminder/collector.rb index 9960bda..a1bd967 100644 --- a/lib/redmine_reminder/collector.rb +++ b/lib/redmine_reminder/collector.rb @@ -26,7 +26,7 @@ def collect_reminders reminders[issue.author][:author] << issue end - if options.send_to_assigned_to? && issue.assigned_to + if options.send_to_assigned_to? && issue.assigned_to && issue.due_date reminders[issue.assigned_to] ||= RedmineReminder::Reminder.new(issue.assigned_to) reminders[issue.assigned_to][:assigned_to] << issue @@ -92,7 +92,7 @@ def issues_due_in_days(use_due_day = true) end scope.where(sql_condition.conditions). - order("#{Issue.table_name}.due_date, #{Project.table_name}.name") + order("#{Project.table_name}.name, #{Issue.table_name}.due_date") end def issue_statuses From f514bdf4c4c6e017951bf651bbbbbaf47e4ca8d0 Mon Sep 17 00:00:00 2001 From: Crespq Date: Tue, 30 Jan 2018 08:01:29 +0100 Subject: [PATCH 5/9] Fixed icon in admin and javascript errors --- assets/javascripts/reminder_configuration.js | 4 ++-- init.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/reminder_configuration.js b/assets/javascripts/reminder_configuration.js index cc90b99..c7eae00 100644 --- a/assets/javascripts/reminder_configuration.js +++ b/assets/javascripts/reminder_configuration.js @@ -1,13 +1,13 @@ var toggleExplicitList = function(selector, list, explicit_value) { var fnToggleList = function() { - if ($(selector).getValue() == explicit_value) { + if ($(selector).val() == explicit_value) { $(list).show(); } else { $(list).hide(); } }; - $(selector).observe('change', fnToggleList); + $(selector).on('change', fnToggleList); fnToggleList(); }; diff --git a/init.rb b/init.rb index e243884..e74ebf6 100644 --- a/init.rb +++ b/init.rb @@ -11,7 +11,7 @@ menu :admin_menu, :reminder_options, { controller: 'reminder_configuration', action: 'edit' }, - html: { class: 'reminder_options_label' } + html: { class: 'icon reminder_options_label' } end require_dependency 'redmine_reminder/hooks' From 3e8595a1dae342d6b8c9b303ad96ea95ced49a18 Mon Sep 17 00:00:00 2001 From: Crespq Date: Thu, 29 Mar 2018 10:55:27 +0200 Subject: [PATCH 6/9] Added Polish translation, thanks to Adam Pielatowski --- config/locales/pl.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 config/locales/pl.yml diff --git a/config/locales/pl.yml b/config/locales/pl.yml new file mode 100644 index 0000000..4d38a92 --- /dev/null +++ b/config/locales/pl.yml @@ -0,0 +1,39 @@ +pl: + mail_reminder_all_day1: "dnia" + mail_reminder_all_day2: "dni" + mail_reminder_all_day5: "dni" + mail_subject_reminder_all1: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}" + mail_body_reminder_auth1: "%{count} zadań do wykonania w ciągu %{days} %{day}, których jesteś autorem:" + mail_body_reminder_assigned1: "%{count} zadań do wykonania w ciągu %{days} %{day}, do których jesteś przypisany:" + mail_body_reminder_watched1: "%{count} zadań do wykonania w ciągu %{days} %{day}, których jesteś obserwatorem:" + mail_body_reminder_custom_user1: "%{count} zadań do wykonania w ciągu %{days} %{day}, w których o Tobie wspomniano:" + mail_subject_reminder_all2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}" + mail_body_reminder_auth2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś autorem:" + mail_body_reminder_assigned2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, do których jesteś przypisany:" + mail_body_reminder_watched2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś obserwatorem:" + mail_body_reminder_custom_user2: "%{count} issues in which you are mentioned are due in the next %{days} %{day}:" + mail_subject_reminder_all5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}" + mail_body_reminder_auth5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś autorem:" + mail_body_reminder_assigned5: "%{count} issues that are assigned to you are due in the next %{days} %{day}:" + mail_body_reminder_watched5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś obserwatorem:" + mail_body_reminder_custom_user5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, w których o Tobie wspomniano:" + + label_reminder_options: "Przypominacz - ustawienia" + label_criteria_task: "Kryteria zadania" + label_completion_date: "Data ukończenia" + label_tasks_due_in: "Zadania, które muszą być ukończonew ciągu następnych" + label_days: "Dni" + label_reminder_recipients: "Odbiorcy przypominacza" + + redmine_reminder: + issue_statuses: + all_opened: "Wszystkie otwarte zadania" + explicit: "Zadania z wybranym statusem" + projects: + all: "Zadania ze wszystkich projektów" + explicit: "Zadania z wybranych projektów" + trackers: + all: "Zadania każdego typu" + explicit: "Wybrane typy zadań" + + field_custom_user: "Użytkownik z pola niestandardowego" From 864b9f62780c705e054276e21e01098bcb3df967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Pavi=C4=87?= Date: Wed, 18 May 2022 08:19:04 +0000 Subject: [PATCH 7/9] Redmine 4.x support --- README.md | 2 +- app/controllers/reminder_configuration_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c8a055..0b50d72 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ You can setup options in administration menu. ## Compatibility -This version supports redmine 3.x. +This version supports redmine 4.x. diff --git a/app/controllers/reminder_configuration_controller.rb b/app/controllers/reminder_configuration_controller.rb index a411f03..235bbde 100644 --- a/app/controllers/reminder_configuration_controller.rb +++ b/app/controllers/reminder_configuration_controller.rb @@ -3,7 +3,7 @@ class ReminderConfigurationController < ApplicationController layout 'admin' - before_filter :require_admin + before_action :require_admin def edit @configuration = ReminderConfiguration.instance From 760aa13e4ecf63a4f2fbe6feaf6e0c3f1c1c82a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Pavi=C4=87?= Date: Wed, 18 May 2022 08:32:28 +0000 Subject: [PATCH 8/9] Redmine 4.x support (Migrations) --- db/migrate/20120911151845_create_reminder_configurations.rb | 2 +- db/migrate/20120911164322_create_reminder_projects.rb | 2 +- db/migrate/20120911164358_create_reminder_issue_statuses.rb | 2 +- db/migrate/20120918093621_create_reminder_trackers.rb | 2 +- ...918095158_add_tracker_selector_to_reminder_configurations.rb | 2 +- .../20170624100352_add_use_due_day_to_reminder_configuration.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/migrate/20120911151845_create_reminder_configurations.rb b/db/migrate/20120911151845_create_reminder_configurations.rb index cb523e4..1e579a8 100644 --- a/db/migrate/20120911151845_create_reminder_configurations.rb +++ b/db/migrate/20120911151845_create_reminder_configurations.rb @@ -1,4 +1,4 @@ -class CreateReminderConfigurations < ActiveRecord::Migration +class CreateReminderConfigurations < ActiveRecord::Migration[5.1] def self.up create_table :reminder_configurations do |t| t.column :days, :integer diff --git a/db/migrate/20120911164322_create_reminder_projects.rb b/db/migrate/20120911164322_create_reminder_projects.rb index 0f9b937..57816af 100644 --- a/db/migrate/20120911164322_create_reminder_projects.rb +++ b/db/migrate/20120911164322_create_reminder_projects.rb @@ -1,4 +1,4 @@ -class CreateReminderProjects < ActiveRecord::Migration +class CreateReminderProjects < ActiveRecord::Migration[5.1] def self.up create_table :reminder_projects do |t| t.column :reminder_configuration_id, :integer diff --git a/db/migrate/20120911164358_create_reminder_issue_statuses.rb b/db/migrate/20120911164358_create_reminder_issue_statuses.rb index ef7fdc2..8b613e3 100644 --- a/db/migrate/20120911164358_create_reminder_issue_statuses.rb +++ b/db/migrate/20120911164358_create_reminder_issue_statuses.rb @@ -1,4 +1,4 @@ -class CreateReminderIssueStatuses < ActiveRecord::Migration +class CreateReminderIssueStatuses < ActiveRecord::Migration[5.1] def self.up create_table :reminder_issue_statuses do |t| t.column :reminder_configuration_id, :integer diff --git a/db/migrate/20120918093621_create_reminder_trackers.rb b/db/migrate/20120918093621_create_reminder_trackers.rb index 14ef362..e07d1d2 100644 --- a/db/migrate/20120918093621_create_reminder_trackers.rb +++ b/db/migrate/20120918093621_create_reminder_trackers.rb @@ -1,4 +1,4 @@ -class CreateReminderTrackers < ActiveRecord::Migration +class CreateReminderTrackers < ActiveRecord::Migration[5.1] def self.up create_table :reminder_trackers do |t| t.column :reminder_configuration_id, :integer diff --git a/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb b/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb index 43915da..758678d 100644 --- a/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb +++ b/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb @@ -1,4 +1,4 @@ -class AddTrackerSelectorToReminderConfigurations < ActiveRecord::Migration +class AddTrackerSelectorToReminderConfigurations < ActiveRecord::Migration[5.1] def self.up unless column_exists? :reminder_configurations, :tracker_selector add_column :reminder_configurations, :tracker_selector, :string diff --git a/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb index 3e09fac..c11c688 100644 --- a/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb +++ b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb @@ -1,4 +1,4 @@ -class AddUseDueDayToReminderConfiguration < ActiveRecord::Migration +class AddUseDueDayToReminderConfiguration < ActiveRecord::Migration[5.1] def change add_column :reminder_configurations, :use_due_day, :boolean, default: false end From 0a1504f636e9d45e261a06714f6a5d0192664e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Pavi=C4=87?= Date: Fri, 20 May 2022 08:49:59 +0000 Subject: [PATCH 9/9] Redmine 4 fixes --- app/models/reminder_all_mailer.rb | 2 +- lib/tasks/reminder_all.rake | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/models/reminder_all_mailer.rb b/app/models/reminder_all_mailer.rb index 75c390a..f11d0ef 100644 --- a/app/models/reminder_all_mailer.rb +++ b/app/models/reminder_all_mailer.rb @@ -39,6 +39,6 @@ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user def self.deliver_reminder_all_if_any(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, without_due_day, days) issues_count = (assigned_issues + auth_issues + watched_issues + custom_user_issues + without_due_day).uniq.size reminder_all(user, assigned_issues, auth_issues, watched_issues, - custom_user_issues, without_due_day, days).deliver if issues_count > 0 + custom_user_issues, without_due_day, days).deliver_later if issues_count > 0 end end diff --git a/lib/tasks/reminder_all.rake b/lib/tasks/reminder_all.rake index a261f57..f5ebe69 100644 --- a/lib/tasks/reminder_all.rake +++ b/lib/tasks/reminder_all.rake @@ -30,17 +30,26 @@ namespace :redmine do collector = RedmineReminder::Collector.new(options) collector.collect_reminders.each do |r| - next unless r.user.active? + users = if r.user.is_a?(User) + [r.user] + else + r.user.users + end + users = users.compact.select{|u| u.active?} + next unless users.blank? ReminderAllMailer.with_synched_deliveries do - ReminderAllMailer.deliver_reminder_all_if_any( - r.user, - r[:assigned_to], - r[:author], - r[:watcher], - r[:custom_user], - r[:without_due_day], - options.days - ) + users.each do |user| + ReminderAllMailer.deliver_reminder_all_if_any( + user, + r[:assigned_to], + r[:author], + r[:watcher], + r[:custom_user], + r[:without_due_day], + options.days + ) + end + end end end