bender-bot 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bender/bot.rb +2 -3
- data/lib/bender/helpers.rb +1 -0
- data/lib/bender/main.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58f5e9eb88fccfcfe2bce294fa9b02014914bae8
|
4
|
+
data.tar.gz: 187c3ff59ad753e5650dc55d44cd6a9532cd3549
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c15e7f21716d9eb37e046d703f79bafd80f186dd570bc2e071b7b974b194c8be6c79a8e37bb926d61d2046e65d3d9eff28de2e8af79c521740e6554db38aab
|
7
|
+
data.tar.gz: 3f6bf43edeba4acabbeeec4aac527153da167f8be8ef53e06b4089043328f45c2a433f587e5ca8850485c592bc89f52c0a2c6ac0511960f753f0d38319960332
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.6
|
data/lib/bender/bot.rb
CHANGED
@@ -99,7 +99,6 @@ class BenderBot
|
|
99
99
|
@sender = sender
|
100
100
|
@message = message
|
101
101
|
|
102
|
-
severity_field = SHOW_FIELDS.key 'Severity'
|
103
102
|
severities = Hash.new { |h,k| h[k] = [] }
|
104
103
|
|
105
104
|
|
@@ -131,7 +130,7 @@ class BenderBot
|
|
131
130
|
unless status =~ /resolved|closed/i
|
132
131
|
'%s (%s - %s) [%s]: %s' % [
|
133
132
|
incident_link(i),
|
134
|
-
short_severity(i['fields'][
|
133
|
+
short_severity(i['fields'][SEVERITY_FIELD]['value']),
|
135
134
|
normalize_value(i['fields']['status']),
|
136
135
|
friendly_date(i['fields']['created']),
|
137
136
|
i['fields']['summary']
|
@@ -162,7 +161,7 @@ class BenderBot
|
|
162
161
|
i['fields']['summary']
|
163
162
|
]
|
164
163
|
|
165
|
-
sev = i['fields'][
|
164
|
+
sev = i['fields'][SEVERITY_FIELD]['value']
|
166
165
|
severities[sev] << repr
|
167
166
|
statuses[status] += 1
|
168
167
|
end
|
data/lib/bender/helpers.rb
CHANGED
data/lib/bender/main.rb
CHANGED
@@ -177,14 +177,19 @@ module Bender
|
|
177
177
|
new_room = room.get_room
|
178
178
|
|
179
179
|
open_incidents = incidents.select do |i|
|
180
|
-
status
|
181
|
-
|
180
|
+
status = normalize_value i['fields']['status']
|
181
|
+
severity = short_severity(i['fields'][SEVERITY_FIELD]['value']),
|
182
|
+
is_open = !(status =~ /resolved|closed/i)
|
183
|
+
is_severe = severity =~ /(SEV1|SEV2)/i
|
184
|
+
is_open && is_severe
|
182
185
|
end
|
183
186
|
|
187
|
+
log.warn open_incidents: open_incidents
|
188
|
+
|
184
189
|
@room_name ||= bot.store['primary_room_name'] || new_room['name']
|
185
190
|
@room_topic ||= bot.store['primary_room_topic'] || new_room['topic']
|
186
191
|
|
187
|
-
@open =
|
192
|
+
@open = nil unless defined? @open
|
188
193
|
|
189
194
|
log.info \
|
190
195
|
primary_room_name: bot.store['primary_room_name'],
|
@@ -196,9 +201,9 @@ module Bender
|
|
196
201
|
open: @open
|
197
202
|
|
198
203
|
if open_incidents.empty?
|
199
|
-
if @open
|
204
|
+
if @open.nil? || @open > 0
|
200
205
|
new_room['name'] = '[NONE] Production Incident'
|
201
|
-
new_room['topic'] = 'Good news everyone! No
|
206
|
+
new_room['topic'] = 'Good news everyone! No high-severity incidents at the moment'
|
202
207
|
begin
|
203
208
|
room.update_room(new_room)
|
204
209
|
rescue NoMethodError
|
@@ -209,14 +214,14 @@ module Bender
|
|
209
214
|
@open = 0
|
210
215
|
|
211
216
|
else
|
212
|
-
if @open.zero?
|
217
|
+
if @open.nil? || @open.zero?
|
213
218
|
@room_name = new_room['name']
|
214
219
|
@room_topic = new_room['topic']
|
215
220
|
end
|
216
221
|
|
217
222
|
unless @open == open_incidents.size
|
218
223
|
new_room['name'] = '[IN PROGRESS] Production Incident'
|
219
|
-
tha_news = open_incidents.size == 1 ? "There's
|
224
|
+
tha_news = open_incidents.size == 1 ? "There's a high-severity incident" : "There are #{open_incidents.size} high-severity incidents"
|
220
225
|
new_room['topic'] = "Terrible news everyone! #{tha_news}"
|
221
226
|
begin
|
222
227
|
room.update_room(new_room)
|