bender-bot 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bender/bot.rb +2 -2
  4. data/lib/bender/main.rb +29 -22
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba655e7af625e66dc7c4b9ddea408d69d9c87061
4
- data.tar.gz: 63f6f815bd1b6bb72873b0caebe2c2b7f6c612be
3
+ metadata.gz: f4d54bc66c4adb36b8818f5e9d99690cfa9e1469
4
+ data.tar.gz: 8228afdc63456046fc27e1b92cc1f88a73c9063e
5
5
  SHA512:
6
- metadata.gz: 61b6aefef6785b768ec92b534b962263dd02f2a3e80b167d97c2e89c23b2fba88149af9efd594e3f7c1bed72a785a24cd61e380f34aebe8848561648e5856538
7
- data.tar.gz: 21af57fe2c566d1978817b2e41c0a97400f50854c0d7f651a8d1fa3bda00901ddbb9d46184275ff9246604f613d11fa3c995e9c8797a947650bb2de1c2e00daf
6
+ metadata.gz: 8a9db7d32cc56a231060920ee4cce4518308c834d67ec2a0b27933dcf499f0bed4ae58c573a5daae024519cfccae70b5eb202cbb965050aeca1645f46a295a90
7
+ data.tar.gz: c910eb660ff6df14bc745d50c638d063dc2d3e4c5afe7518d5b82d57774eb128bd738f1f3a40679bf543b9846c012ccfcb7ca3200fef621bcfab9e32e6442d59
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
@@ -160,7 +160,7 @@ class BenderBot
160
160
  unless status =~ /resolved|closed/i
161
161
  '%s (%s - %s) [%s]: %s' % [
162
162
  incident_link(i),
163
- short_severity(i['fields'][SEVERITY_FIELD]['value']),
163
+ short_severity(i['fields'][SEVERITY_FIELD] && i['fields'][SEVERITY_FIELD]['value']),
164
164
  normalize_value(i['fields']['status']),
165
165
  friendly_date(i['fields']['created']),
166
166
  i['fields']['summary']
@@ -191,7 +191,7 @@ class BenderBot
191
191
  i['fields']['summary']
192
192
  ]
193
193
 
194
- sev = i['fields'][SEVERITY_FIELD]['value']
194
+ sev = i['fields'][SEVERITY_FIELD]['value'] rescue ''
195
195
  severities[sev] << repr
196
196
  statuses[status] += 1
197
197
  end
@@ -134,7 +134,7 @@ module Bender
134
134
 
135
135
  open_incidents = incidents.select do |i|
136
136
  status = normalize_value i['fields']['status']
137
- severity = short_severity(i['fields'][SEVERITY_FIELD]['value'])
137
+ severity = short_severity(i['fields'][SEVERITY_FIELD]['value']) rescue ''
138
138
  is_open = !(status =~ /resolved|closed/i)
139
139
  is_severe = severity =~ /(SEV1|SEV2)/i
140
140
  is_open && is_severe
@@ -276,35 +276,42 @@ module Bender
276
276
 
277
277
 
278
278
  def periodically_refresh_group bot
279
- req_path = '/rest/api/2/group'
280
- req_params = QueryParams.encode \
281
- groupname: config[:jira_group],
282
- expand: 'users'
283
-
284
- uri = URI(config[:jira_site] + req_path + '?' + req_params)
285
- http = Net::HTTP.new uri.hostname, uri.port
286
-
287
- req = Net::HTTP::Get.new uri
288
- req.basic_auth config[:jira_user], config[:jira_pass]
289
- req['Content-Type'] = 'application/json'
290
- req['Accept'] = 'application/json'
291
-
292
279
  Thread.new do
293
280
  loop do
294
281
  begin
295
- resp = http.request req
296
- data = JSON.parse resp.body
282
+ req_path = '/rest/api/2/group/member'
283
+ is_last, values, start = false, [], 0
284
+ until is_last
285
+ req_params = QueryParams.encode \
286
+ groupname: config[:jira_group],
287
+ startAt: start
288
+
289
+ uri = URI(config[:jira_site] + req_path + '?' + req_params)
290
+ http = Net::HTTP.new uri.hostname, uri.port
291
+
292
+ req = Net::HTTP::Get.new uri
293
+ req.basic_auth config[:jira_user], config[:jira_pass]
294
+ req['Content-Type'] = 'application/json'
295
+ req['Accept'] = 'application/json'
296
+
297
+ resp = http.request req
298
+ data = JSON.parse resp.body
299
+ values += data['values']
300
+ is_last = data['isLast']
301
+ start += data['maxResults']
302
+ end
303
+
304
+ user_names = values.map { |u| u['displayName'] }
305
+ bot.store['group'] = user_names
306
+ sleep config[:group_refresh]
307
+
297
308
  rescue StandardError => e
298
309
  log.error \
299
310
  message: 'Could not periodically refresh group',
300
- error: e.class
311
+ error: e.class,
312
+ data: resp.body
301
313
  sleep 5
302
- next
303
314
  end
304
-
305
- user_names = data['users']['items'].map { |u| u['displayName'] }
306
- bot.store['group'] = user_names
307
- sleep config[:group_refresh]
308
315
  end
309
316
  end
310
317
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bender-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor