diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-16 20:54:38 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-16 20:54:38 +0100 |
commit | 2cca449f78116aa02072e2e6c5036f63c2ec962b (patch) | |
tree | ba06e0f8d59a50847b5a7827f07b603e9793aa68 /lib/mauve/notification.rb | |
parent | ccd064ab3e7e140e851f84e9d1e7f3b987c7b9d1 (diff) |
Added time-fixation when processing "during" clauses, I think.
Diffstat (limited to 'lib/mauve/notification.rb')
-rw-r--r-- | lib/mauve/notification.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb index 920f1b1..a9795f3 100644 --- a/lib/mauve/notification.rb +++ b/lib/mauve/notification.rb @@ -195,7 +195,7 @@ module Mauve # @param [Array] already_sent_to A list of people that have already received this alert. # # @return [Array] The list of people that have received this alert. - def notify(alert, already_sent_to = []) + def notify(alert, already_sent_to = [], at=Time.now) if people.nil? or people.empty? logger.warn "No people found in for notification #{list}" @@ -203,7 +203,7 @@ module Mauve end # Should we notify at all? - return already_sent_to unless DuringRunner.new(Time.now, alert, &during).now? + return already_sent_to unless DuringRunner.new(at, alert, &during).now? people.collect do |person| case person @@ -236,13 +236,15 @@ module Mauve # @param [Mauve::Alert] alert The alert in question # @return [Time or nil] The time a reminder should get sent, or nil if it # should never get sent again. - def remind_at_next(alert) + def remind_at_next(alert, at = Time.now) return nil unless alert.raised? - if DuringRunner.new(Time.now, alert, &during).now? - return DuringRunner.new(Time.now, alert, &during).find_next(every) + dr = DuringRunner.new(at, alert, &during) + + if dr.now? + return dr.find_next(every) else - return DuringRunner.new(Time.now, alert, &during).find_next() + return dr.find_next() end end |