whoops 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/whoops/event.rb +5 -11
- data/app/models/whoops/event_group.rb +44 -4
- data/app/models/whoops/notification_rule.rb +1 -1
- metadata +8 -22
data/app/models/whoops/event.rb
CHANGED
@@ -15,19 +15,13 @@ class Whoops::Event
|
|
15
15
|
|
16
16
|
def self.record(params)
|
17
17
|
params = params.with_indifferent_access
|
18
|
-
|
19
|
-
event_group_params
|
20
|
-
event_group_params[:identifier]
|
18
|
+
|
19
|
+
event_group_params = params.slice(*Whoops::EventGroup.field_names)
|
20
|
+
event_group_params[:identifier] = params[:event_group_identifier]
|
21
21
|
event_group_params[:last_recorded_at] = params[:event_time]
|
22
|
+
event_group_params
|
23
|
+
event_group = Whoops::EventGroup.handle_new_event(event_group_params)
|
22
24
|
|
23
|
-
event_group = Whoops::EventGroup.first(:conditions => event_group_params.slice(*Whoops::EventGroup.identifying_fields))
|
24
|
-
if event_group
|
25
|
-
event_group.attributes = event_group_params
|
26
|
-
event_group.save
|
27
|
-
else
|
28
|
-
event_group = Whoops::EventGroup.create(event_group_params)
|
29
|
-
end
|
30
|
-
|
31
25
|
event_params = params.slice(*Whoops::Event.field_names)
|
32
26
|
event_group.events.create(event_params)
|
33
27
|
end
|
@@ -3,17 +3,46 @@ class Whoops::EventGroup
|
|
3
3
|
include Mongoid::Document
|
4
4
|
include FieldNames
|
5
5
|
|
6
|
-
[
|
6
|
+
[
|
7
|
+
:service,
|
8
|
+
:environment,
|
9
|
+
:event_type,
|
10
|
+
:message,
|
11
|
+
:identifier,
|
12
|
+
:logging_strategy_name
|
13
|
+
].each do |string_field|
|
7
14
|
field string_field, :type => String
|
8
15
|
end
|
16
|
+
|
9
17
|
field :last_recorded_at, :type => DateTime
|
18
|
+
field :archived, :type => Boolean, :default => false
|
10
19
|
field :notify_on_next_occurrence, :type => Boolean, :default => true
|
11
20
|
|
21
|
+
class << self
|
22
|
+
def handle_new_event(params)
|
23
|
+
identifying_params = params.slice(*Whoops::EventGroup.identifying_fields)
|
24
|
+
event_group = Whoops::EventGroup.first(:conditions => identifying_params)
|
25
|
+
|
26
|
+
if event_group
|
27
|
+
event_group.attributes = params
|
28
|
+
else
|
29
|
+
event_group = Whoops::EventGroup.new(params)
|
30
|
+
end
|
31
|
+
|
32
|
+
if event_group.valid?
|
33
|
+
event_group.send_notifications
|
34
|
+
event_group.save
|
35
|
+
end
|
36
|
+
|
37
|
+
event_group
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
12
41
|
has_many :events, :class_name => "Whoops::Event"
|
13
42
|
|
14
43
|
validates_presence_of :identifier, :event_type, :service, :message
|
15
44
|
|
16
|
-
|
45
|
+
before_save :handle_archival
|
17
46
|
|
18
47
|
def self.identifying_fields
|
19
48
|
field_names - ["message", "last_recorded_at"]
|
@@ -32,11 +61,22 @@ class Whoops::EventGroup
|
|
32
61
|
end
|
33
62
|
services
|
34
63
|
end
|
64
|
+
|
65
|
+
def handle_archival
|
66
|
+
if self.archived_change && !self.new_record?
|
67
|
+
if self.archived
|
68
|
+
self.notify_on_next_occurrence = false
|
69
|
+
else
|
70
|
+
self.notify_on_next_occurrence = true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
35
75
|
|
36
76
|
def send_notifications
|
77
|
+
return unless self.notify_on_next_occurrence
|
37
78
|
matcher = Whoops::NotificationRule::Matcher.new(self)
|
38
|
-
Whoops::NotificationMailer.event_notification(self, matcher.matches)
|
79
|
+
Whoops::NotificationMailer.event_notification(self, matcher.matches).deliver unless matcher.matches.empty?
|
39
80
|
self.notify_on_next_occurrence = false
|
40
81
|
end
|
41
|
-
|
42
82
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Higginbotham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
type: :development
|
152
152
|
version_requirements: *id009
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: fabrication
|
155
155
|
prerelease: false
|
156
156
|
requirement: &id010 !ruby/object:Gem::Requirement
|
157
157
|
none: false
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
type: :development
|
166
166
|
version_requirements: *id010
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: faker
|
169
169
|
prerelease: false
|
170
170
|
requirement: &id011 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
@@ -178,24 +178,10 @@ dependencies:
|
|
178
178
|
version: "0"
|
179
179
|
type: :development
|
180
180
|
version_requirements: *id011
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: faker
|
183
|
-
prerelease: false
|
184
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
|
-
requirements:
|
187
|
-
- - ">="
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
hash: 3
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
version: "0"
|
193
|
-
type: :development
|
194
|
-
version_requirements: *id012
|
195
181
|
- !ruby/object:Gem::Dependency
|
196
182
|
name: capybara
|
197
183
|
prerelease: false
|
198
|
-
requirement: &
|
184
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
199
185
|
none: false
|
200
186
|
requirements:
|
201
187
|
- - ">="
|
@@ -207,7 +193,7 @@ dependencies:
|
|
207
193
|
- 0
|
208
194
|
version: 0.4.0
|
209
195
|
type: :development
|
210
|
-
version_requirements: *
|
196
|
+
version_requirements: *id012
|
211
197
|
description: A Rails engine which receives logs and provides an interface for them
|
212
198
|
email:
|
213
199
|
executables: []
|