diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2013-05-14 13:42:41 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2013-05-14 13:42:41 +0100 |
commit | e08051b78bae61dd42b48f4f8d9d086823ddbd2a (patch) | |
tree | 11637803fbfb33e7637e2e35af780773d83ca53c /lib/mauve/configuration_builders | |
parent | 829a59b0a2a0b470781b8ebd44481c02fb049421 (diff) |
Database now queried to work out if a notification should be suppressed.
Diffstat (limited to 'lib/mauve/configuration_builders')
-rw-r--r-- | lib/mauve/configuration_builders/person.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb index f171d10..9cc09ab 100644 --- a/lib/mauve/configuration_builders/person.rb +++ b/lib/mauve/configuration_builders/person.rb @@ -51,10 +51,15 @@ module Mauve def suppress_notifications_after(h) raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless h.kind_of?(Hash) - h.each do |k,v| - raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless k.is_a?(Integer) and v.is_a?(Integer) - - @result.notification_thresholds[v] = Array.new(k) + h.each do |number_of_alerts,in_period| + raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless number_of_alerts.is_a?(Integer) and in_period.is_a?(Integer) + + @result.suppress_notifications_after[in_period] = number_of_alerts + # History.all( + # :limit => number_of_alerts, + # :order => :created_at.desc, + # :type => "notification", + # :event.like => '% succeeded') end end @@ -87,7 +92,7 @@ module Mauve # # Add a default notification threshold # - person.notification_thresholds[600] = Array.new(5) if person.notification_thresholds.empty? + person.suppress_notifications_after[600] = 5 if person.suppress_notifications_after.empty? # # Add a default notify clause |