diff options
| author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-05-03 18:35:59 +0100 | 
|---|---|---|
| committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-05-03 18:35:59 +0100 | 
| commit | 442e97f45ca582fdfbdd57f558e9fa82c8dfd4d3 (patch) | |
| tree | 7655c4c77ef2569e25075a7bd17adb82da7ac180 /lib/mauve/alert.rb | |
| parent | 2b89a1440aae4d4de9d5ffa036df49c5652d64ef (diff) | |
Notify anyone who has contributed to an alert's history since its last raise,
either by acknowledging, or by being notified about it.
Diffstat (limited to 'lib/mauve/alert.rb')
| -rw-r--r-- | lib/mauve/alert.rb | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb index a5cb885..d3bcf7a 100644 --- a/lib/mauve/alert.rb +++ b/lib/mauve/alert.rb @@ -622,6 +622,35 @@ module Mauve        !raised?      end +    # Work out an array of extra people to notify. +    # +    # @return [Array] array of persons +    def extra_people_to_notify +      last_raised_at = self.raised_at + +      if last_raised_at.nil? +        last_raise = self.histories(:event => "RAISED", :limit => 1, :order => :created_at.desc).first +        last_raised_at = last_raise.created_at unless last_raise.nil? +      end + + +      return [] if last_raised_at.nil? + +      notifications = [] + +      # +      # Find all the people who've been involved with this alert since it was +      # last raised. +      # +      users = histories.all(:created_at.gte => last_raised_at).collect do |h| +        h.user +      end + [self.acknowledged_by] + +      users.compact.sort.uniq.collect do |user| +        person = Configuration.current.people[user] +      end.compact +    end +      class << self        # Removes or cleans HTML from a string | 
