diff --git app/models/mailer.rb app/models/mailer.rb index 4bfa45b..b98ea6e 100644 --- app/models/mailer.rb +++ app/models/mailer.rb @@ -324,12 +324,16 @@ class Mailer < ActionMailer::Base # Sends reminders to issue assignees # Available options: - # * :days => how many days in the future to remind about (defaults to 7) - # * :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/group ids who should be reminded - # * :version => name of target version for filtering issues (defaults to none) + # * :days => how many days in the future to remind about (defaults to 7) + # * :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/group ids who should be reminded + # * :version => name of target version for filtering issues (defaults to none) + # * :respect_nonworking_days => if true the non working days setting will be used to calculate the date difference def self.reminders(options={}) + + extend Redmine::Utils::DateCalculation + days = options[:days] || 7 project = options[:project] ? Project.find(options[:project]) : nil tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil @@ -339,6 +343,11 @@ class Mailer < ActionMailer::Base end user_ids = options[:users] + if options[:respect_nonworking_days] + working_day_count = working_days(Date.today, days.day.from_now.to_date) + days = days + (days - working_day_count) + end + 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 diff --git lib/tasks/reminder.rake lib/tasks/reminder.rake index 3807297..35dcfc6 100644 --- lib/tasks/reminder.rake +++ lib/tasks/reminder.rake @@ -37,6 +37,7 @@ namespace :redmine do options[:tracker] = ENV['tracker'].to_i if ENV['tracker'] options[:users] = (ENV['users'] || '').split(',').each(&:strip!) options[:version] = ENV['version'] if ENV['version'] + options[:respect_nonworking_days] = !!ENV['respect_nonworking_days'] Mailer.with_synched_deliveries do Mailer.reminders(options)