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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dea2fba9600c9e3c69175188361d1ecc25963afa
4
- data.tar.gz: 6d5dd7070e5be5f27054644d232cec5f128ba01a
3
+ metadata.gz: 58f5e9eb88fccfcfe2bce294fa9b02014914bae8
4
+ data.tar.gz: 187c3ff59ad753e5650dc55d44cd6a9532cd3549
5
5
  SHA512:
6
- metadata.gz: 6012bac14aed3d48856287d444e94f08b45d69cd15f2cb032bb5c0f92f2bfc65a5e0f1df2c84706926850da9edb80496bb2e17f4774fb91d6c0ff8394a8f5771
7
- data.tar.gz: 894f41cec02c47f13f3d02d00d1c9bb7c9b542d0a2acb6c4cf6523c34b01634183a3066938e96fc3a2fbaea8c965e65d14500f0b93e5680d59424f873b07e1a7
6
+ metadata.gz: 52c15e7f21716d9eb37e046d703f79bafd80f186dd570bc2e071b7b974b194c8be6c79a8e37bb926d61d2046e65d3d9eff28de2e8af79c521740e6554db38aab
7
+ data.tar.gz: 3f6bf43edeba4acabbeeec4aac527153da167f8be8ef53e06b4089043328f45c2a433f587e5ca8850485c592bc89f52c0a2c6ac0511960f753f0d38319960332
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -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'][severity_field]['value']),
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'][severity_field]['value']
164
+ sev = i['fields'][SEVERITY_FIELD]['value']
166
165
  severities[sev] << repr
167
166
  statuses[status] += 1
168
167
  end
@@ -30,6 +30,7 @@ module Helpers
30
30
  'updated' => 'Updated'
31
31
  }
32
32
 
33
+ SEVERITY_FIELD = SHOW_FIELDS.key('Severity')
33
34
 
34
35
  QUOTES = [
35
36
  'Bite my shiny metal ass!',
@@ -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 = normalize_value i['fields']['status']
181
- !(status =~ /resolved|closed/i)
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 = 1 unless defined? @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 open incidents at the moment'
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 an open incident" : "There are #{open_incidents.size} open incidents"
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bender-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer