bpm_manager 1.0.28 → 1.0.29

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e07a91578a92ae66fc27c4d953c720cc3a479239
4
- data.tar.gz: 1128a8f026fcdd7a7b7fe0c8305e02943d6c801f
3
+ metadata.gz: 022aba1cba59e521272deaf42fc6b964035eda9b
4
+ data.tar.gz: 1a8fe793a457a6e01a377bc7611c9078ed8bfeab
5
5
  SHA512:
6
- metadata.gz: 08e339575f7d7fece25481db646bb7182b2521909dbbdb0e3bdd51fc259d1cf99dc337d9bff88638196701dbb75935a2867990bb424295514f30585dc8cd83f4
7
- data.tar.gz: 1d086c3c55475dc77b4f143a4c504ffd90fa3c558c15a43011f50b48b330b7e7b48fb27d95e3137d01ea8a827d1ce6efc2ad018c95183aa3ed588c3ce2e59e33
6
+ metadata.gz: 533bc9a9009fe4a433100097f26b3c70151a5fea0e4c123fc355d4ffd80a71a14bc483915db3afc8806bd79363d2311e2959505e7fad34127a8d4e4b97f58633
7
+ data.tar.gz: 8e9d00cafdd7544bd2c62b51292f393bcccb9881aedec394cae1b4ca76472dc557af9aab972fbb1dc7ec25368080c2af16280f2538a776593bec6483713a7e45
@@ -169,14 +169,13 @@ module BpmManager
169
169
 
170
170
  unless my_process.nil?
171
171
  sla = OpenStruct.new(:process => OpenStruct.new)
172
- start = Time.at(my_process['start']/1000)
172
+ start_time = Time.at(my_process['start']/1000)
173
+ end_time = my_process['start'].nil? ? Time.now : Time.at(my_process['start']/1000)
173
174
 
174
175
  # Calculates the process sla
175
- sla.process.status = calculate_sla(start, process_sla_hours, warning_offset_percent)
176
- sla.process.status_name = (calculate_sla(start, process_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(start, process_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
177
- sla.process.percentages = calculate_sla_percent(start, process_sla_hours, warning_offset_percent)
178
- else
179
- sla = nil
176
+ sla.process.status = calculate_sla(start_time, end_time, process_sla_hours, warning_offset_percent)
177
+ sla.process.status_name = (calculate_sla(start_time, end_time, process_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(start_time, end_time, process_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
178
+ sla.process.percentages = calculate_sla_percent(start_time, end_time, process_sla_hours, warning_offset_percent)
180
179
  end
181
180
 
182
181
  return sla
@@ -190,47 +189,45 @@ module BpmManager
190
189
  sla = OpenStruct.new(:task => OpenStruct.new, :process => OpenStruct.new)
191
190
 
192
191
  # Calculates the process sla
193
- sla.process.status = calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent)
194
- sla.process.status_name = (calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
195
- sla.process.percentages = calculate_sla_percent(my_task.process.start_on, process_sla_hours, warning_offset_percent)
192
+ sla.process.status = calculate_sla(my_task.process.start_on, my_task.process.end_on, process_sla_hours, warning_offset_percent)
193
+ sla.process.status_name = (calculate_sla(my_task.process.start_on, my_task.process.end_on, process_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.process.start_on, my_task.process.end_on, process_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
194
+ sla.process.percentages = calculate_sla_percent(my_task.process.start_on, my_task.process.end_on, process_sla_hours, warning_offset_percent)
196
195
 
197
196
  # Calculates the task sla
198
- sla.task.status = calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent)
199
- sla.task.status_name = (calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
200
- sla.task.percentages = calculate_sla_percent(my_task.created_on, task_sla_hours, warning_offset_percent)
201
- else
202
- sla = nil
197
+ sla.task.status = calculate_sla(my_task.created_on, nil, task_sla_hours, warning_offset_percent)
198
+ sla.task.status_name = (calculate_sla(my_task.created_on, nil, task_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.created_on, nil, task_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due')
199
+ sla.task.percentages = calculate_sla_percent(my_task.created_on, nil, task_sla_hours, warning_offset_percent)
203
200
  end
204
201
 
205
202
  return sla
206
203
  end
207
204
 
208
205
  # Private class methods
209
- def self.calculate_sla(start, sla_hours = 0.0, offset = 20)
206
+ def self.calculate_sla(start_time, end_time = Time.now, sla_hours = 0.0, offset = 20)
210
207
  hours = sla_hours.to_f * 3600 # Converts to seconds and calculates warning offset
211
- warn = start.utc + hours * ((100.0 - offset) / 100)
212
- total = start.utc + hours
208
+ warn = start_time.utc + hours * ((100.0 - offset) / 100)
209
+ total = start_time.utc + hours
213
210
 
214
211
  # Returns the status
215
- Time.now.utc <= warn ? 0 : ( warn < Time.now.utc && Time.now.utc <= total ? 1 : 2 )
212
+ end_time.utc <= warn ? 0 : ( warn < end_time.utc && end_time.utc <= total ? 1 : 2 )
216
213
  end
217
214
  private_class_method :calculate_sla
218
215
 
219
- def self.calculate_sla_percent(start, sla_hours = 0.0, offset = 20)
216
+ def self.calculate_sla_percent(start_time, end_time = Time.now, sla_hours = 0.0, offset = 20)
220
217
  sla_hours = sla_hours * 3600.0 # converts to seconds
221
218
  offset_pcg = (100.0 - offset) / 100.0
222
219
  percent = OpenStruct.new
223
220
 
224
221
  unless sla_hours < 1 # it's zero or negative
225
- if Time.now.utc > (start.utc + sla_hours) # Ruby Red
226
- total = (Time.now.utc - start.utc).to_f
222
+ if end_time.utc > (start_time.utc + sla_hours) # Ruby Red
223
+ total = (end_time.utc - start_time.utc).to_f
227
224
  percent.green = (sla_hours * offset_pcg / total * 100).round(2)
228
225
  percent.yellow = ((sla_hours / total * 100) - percent.green).round(2)
229
226
  percent.red = (100 - percent.yellow - percent.green).round(2)
230
227
  else # Still Green
231
228
  total = sla_hours
232
- percent.green = Time.now.utc <= start.utc + total * offset_pcg ? ((100-offset) - (((start.utc + total * offset_pcg) - Time.now.utc) * 100).to_f / (total * offset_pcg).to_f).round(2) : 100 - offset
233
- percent.yellow = Time.now.utc <= start.utc + total * offset_pcg ? 0.0 : (offset - (start.utc + total - Time.now.utc).to_f * 100 / (total * offset_pcg).to_f).round(2)
229
+ percent.green = end_time.utc <= start_time.utc + total * offset_pcg ? ((100-offset) - (((start_time.utc + total * offset_pcg) - end_time.utc) * 100).to_f / (total * offset_pcg).to_f).round(2) : 100 - offset
230
+ percent.yellow = end_time.utc <= start_time.utc + total * offset_pcg ? 0.0 : (offset - (start_time.utc + total - end_time.utc).to_f * 100 / (total * offset_pcg).to_f).round(2)
234
231
  percent.red = 0.0
235
232
  end
236
233
 
@@ -255,37 +252,38 @@ module BpmManager
255
252
  unless input['taskSummaryList'].nil? || input['taskSummaryList'].empty?
256
253
  input['taskSummaryList'].each do |task|
257
254
  task_query = self.task_query(task['id'])
258
- my_task = OpenStruct.new
259
- my_task.id = task['id']
260
- my_task.name = task['name']
261
- my_task.subject = task['subject']
262
- my_task.description = task['description']
263
- my_task.status = task['status']
264
- my_task.priority = task['priority']
265
- my_task.skippable = task['skippable']
266
- my_task.created_on = Time.at(task['created-on']/1000)
267
- my_task.active_on = Time.at(task['activation-time']/1000)
255
+ my_task = OpenStruct.new
256
+ my_task.id = task['id']
257
+ my_task.name = task['name']
258
+ my_task.subject = task['subject']
259
+ my_task.description = task['description']
260
+ my_task.status = task['status']
261
+ my_task.priority = task['priority']
262
+ my_task.skippable = task['skippable']
263
+ my_task.created_on = Time.at(task['created-on']/1000)
264
+ my_task.active_on = Time.at(task['activation-time']/1000)
268
265
  my_task.process_instance_id = task['process-instance-id']
269
- my_task.process_id = task['process-id']
270
- my_task.process_session_id = task['process-session-id']
271
- my_task.deployment_id = task['deployment-id']
272
- my_task.quick_task_summary = task['quick-task-summary']
273
- my_task.parent_id = task['parent_id']
274
- my_task.form_name = task_query['form-name']
275
- my_task.creator = task_query['taskData']['created-by']
276
- my_task.owner = task['actual-owner']
277
- my_task.data = task
266
+ my_task.process_id = task['process-id']
267
+ my_task.process_session_id = task['process-session-id']
268
+ my_task.deployment_id = task['deployment-id']
269
+ my_task.quick_task_summary = task['quick-task-summary']
270
+ my_task.parent_id = task['parent_id']
271
+ my_task.form_name = task_query['form-name']
272
+ my_task.creator = task_query['taskData']['created-by']
273
+ my_task.owner = task['actual-owner']
274
+ my_task.data = task
278
275
 
279
- my_task.process = OpenStruct.new
280
- my_task.process.data = self.process_instance(task['process-instance-id'])
276
+ my_task.process = OpenStruct.new
277
+ my_task.process.data = self.process_instance(task['process-instance-id'])
281
278
  my_task.process.deployment_id = task['deployment-id']
282
- my_task.process.id = my_task.process.data['process-id']
283
- my_task.process.instance_id = my_task.process.data['process-instance-id']
284
- my_task.process.start_on = my_task.process.data['start'].nil? ? Time.now : Time.at(my_task.process.data['start']/1000)
285
- my_task.process.name = my_task.process.data['process-name']
286
- my_task.process.version = my_task.process.data['process-version']
287
- my_task.process.creator = my_task.process.data['identity']
288
- my_task.process.variables = self.process_instance_variables(my_task.process.instance_id)
279
+ my_task.process.id = my_task.process.data['process-id']
280
+ my_task.process.instance_id = my_task.process.data['process-instance-id']
281
+ my_task.process.start_on = my_task.process.data['start'].nil? ? Time.now : Time.at(my_task.process.data['start']/1000)
282
+ my_task.process.end_on = my_task.process.data['end'].nil? ? nil : Time.at(my_task.process.data['end']/1000)
283
+ my_task.process.name = my_task.process.data['process-name']
284
+ my_task.process.version = my_task.process.data['process-version']
285
+ my_task.process.creator = my_task.process.data['identity']
286
+ my_task.process.variables = self.process_instance_variables(my_task.process.instance_id)
289
287
  tasks << my_task
290
288
  end
291
289
  end
@@ -298,39 +296,40 @@ module BpmManager
298
296
 
299
297
  unless input['taskInfoList'].nil? || input['taskInfoList'].empty?
300
298
  input['taskInfoList'].each do |tasks_array|
301
- task = tasks_array['taskSummaries'].max_by{|e| e['created-on']} # Selects only the last active task
302
- task_query = self.task_query(task['id'])
303
- my_task = OpenStruct.new
304
- my_task.id = task['id']
305
- my_task.name = task['name']
306
- my_task.subject = task['subject']
307
- my_task.description = task['description']
308
- my_task.status = task['status']
309
- my_task.priority = task['priority']
310
- my_task.skippable = task['skippable']
311
- my_task.created_on = Time.at(task['created-on']/1000)
312
- my_task.active_on = Time.at(task['activation-time']/1000)
299
+ task = tasks_array['taskSummaries'].max_by{|e| e['created-on']} # Selects only the last active task
300
+ task_query = self.task_query(task['id'])
301
+ my_task = OpenStruct.new
302
+ my_task.id = task['id']
303
+ my_task.name = task['name']
304
+ my_task.subject = task['subject']
305
+ my_task.description = task['description']
306
+ my_task.status = task['status']
307
+ my_task.priority = task['priority']
308
+ my_task.skippable = task['skippable']
309
+ my_task.created_on = Time.at(task['created-on']/1000)
310
+ my_task.active_on = Time.at(task['activation-time']/1000)
313
311
  my_task.process_instance_id = task['process-instance-id']
314
- my_task.process_id = task['process-id']
315
- my_task.process_session_id = task['process-session-id']
316
- my_task.deployment_id = task['deployment-id']
317
- my_task.quick_task_summary = task['quick-task-summary']
318
- my_task.parent_id = task['parent_id']
319
- my_task.form_name = task_query['form-name']
320
- my_task.creator = task_query['taskData']['created-by']
321
- my_task.owner = task['actual-owner']
322
- my_task.data = task
312
+ my_task.process_id = task['process-id']
313
+ my_task.process_session_id = task['process-session-id']
314
+ my_task.deployment_id = task['deployment-id']
315
+ my_task.quick_task_summary = task['quick-task-summary']
316
+ my_task.parent_id = task['parent_id']
317
+ my_task.form_name = task_query['form-name']
318
+ my_task.creator = task_query['taskData']['created-by']
319
+ my_task.owner = task['actual-owner']
320
+ my_task.data = task
323
321
 
324
- my_task.process = OpenStruct.new
325
- my_task.process.data = self.process_instance(task['process-instance-id'])
322
+ my_task.process = OpenStruct.new
323
+ my_task.process.data = self.process_instance(task['process-instance-id'])
326
324
  my_task.process.deployment_id = task['deployment-id']
327
- my_task.process.id = my_task.process.data['process-id']
328
- my_task.process.instance_id = my_task.process.data['process-instance-id']
329
- my_task.process.start_on = my_task.process.data['start'].nil? ? Time.now : Time.at(my_task.process.data['start']/1000)
330
- my_task.process.name = my_task.process.data['process-name']
331
- my_task.process.version = my_task.process.data['process-version']
332
- my_task.process.creator = my_task.process.data['identity']
333
- my_task.process.variables = self.process_instance_variables(my_task.process.instance_id)
325
+ my_task.process.id = my_task.process.data['process-id']
326
+ my_task.process.instance_id = my_task.process.data['process-instance-id']
327
+ my_task.process.start_on = my_task.process.data['start'].nil? ? Time.now : Time.at(my_task.process.data['start']/1000)
328
+ my_task.process.end_on = my_task.process.data['end'].nil? ? nil : Time.at(my_task.process.data['end']/1000)
329
+ my_task.process.name = my_task.process.data['process-name']
330
+ my_task.process.version = my_task.process.data['process-version']
331
+ my_task.process.creator = my_task.process.data['identity']
332
+ my_task.process.variables = self.process_instance_variables(my_task.process.instance_id)
334
333
  tasks << my_task
335
334
  end
336
335
  end
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "1.0.28"
2
+ VERSION = "1.0.29"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpm_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.28
4
+ version: 1.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client