aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/history.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-08 17:24:08 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-08 17:24:08 +0100
commit1ac431fa21907a2a95d87901825cff3dc462746b (patch)
treebee0d55b3fb936bdd77095cdb32970379f4c82d0 /lib/mauve/history.rb
parentfdfd98e5117b269d1f30dfbbd9c1cf2cf037658a (diff)
Added first basic history functionality, and rejigged when notify is called for
an alert.
Diffstat (limited to 'lib/mauve/history.rb')
-rw-r--r--lib/mauve/history.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/mauve/history.rb b/lib/mauve/history.rb
new file mode 100644
index 0000000..6c4969b
--- /dev/null
+++ b/lib/mauve/history.rb
@@ -0,0 +1,26 @@
+# encoding: UTF-8
+require 'mauve/datamapper'
+require 'log4r'
+
+module Mauve
+ class History
+ include DataMapper::Resource
+
+ # so .first always returns the most recent update
+ default_scope(:default).update(:order => [:created_at.desc, :id.desc])
+
+ property :id, Serial
+ property :alert_id, Integer, :required => true
+ property :type, String, :required => true, :default => "unknown"
+ property :event, Text, :required => true
+ property :created_at, DateTime
+
+ belongs_to :alert
+
+ def logger
+ Log4r::Logger.new self.class.to_s
+ end
+
+ end
+
+end