aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-11-27 16:16:00 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-11-27 16:16:00 +0000
commitcbe6e159ea00b7c63279d96c64eb90fdbfd4c275 (patch)
tree1eb9c10f1a77e6666108fdf14f29ebf252e3b86d /lib/mauve
parent4213c0713cf65dd61fce2d40ded23da25c18270e (diff)
Don't do useless database fetches, when super/dirty_attributes can be
used.
Diffstat (limited to 'lib/mauve')
-rw-r--r--lib/mauve/alert.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb
index 024ce5c..ab13736 100644
--- a/lib/mauve/alert.rb
+++ b/lib/mauve/alert.rb
@@ -217,19 +217,18 @@ module Mauve
# The alert subject
#
# @return [String]
- def subject; attribute_get(:subject) || attribute_get(:source) || "not set" ; end
+ def subject; super || self.source || "not set" ; end
# The alert detail
#
# @return [String]
- def detail; attribute_get(:detail) || "_No detail set._" ; end
+ def detail; super || "_No detail set._" ; end
#
# Set the subject -- this clears the cached_alert_group.
#
def subject=(s)
self.cached_alert_group = nil
- @subject_ips = nil
attribute_set(:subject, s)
end
@@ -288,7 +287,7 @@ module Mauve
# This is to stop datamapper inserting duff dates into the database.
#
def check_dates
- bad_dates = self.attributes.find_all do |key, value|
+ bad_dates = self.dirty_attributes.find_all do |key, value|
value.is_a?(Time) and (value < (Time.now - 3650.days) or value > (Time.now + 3650.days))
end
@@ -299,7 +298,6 @@ module Mauve
end
end
-
# Remove all history for an alert, when an alert is destroyed.
#
#