bpm_manager 0.9.16 → 0.10.0

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: 4e3b5c1eadedf5de66e46f004736de6881b0fe8d
4
- data.tar.gz: b0d13b931a1960e2002fe7289a04ede0e2b80f1e
3
+ metadata.gz: 3bd20d32447d3f004ed4b68d85be370981b2b43c
4
+ data.tar.gz: dcab2e8e810a2c815bd75a001ebc76dc1389890c
5
5
  SHA512:
6
- metadata.gz: b21c4533a24490bdb5fcd99b00037aa649f35dfc9bea8c450e0b44936690e0e5fee6d3c8542b32e32e46bf1653f2b3e041a6e3a138bc842340fc755a8419b921
7
- data.tar.gz: 3d6815e7f7655788a1440ed8cdb267833317e266983d6fe352ae5b48e5e114202a8416dd8ba6a498317134e7b8672be7686436d84dad573c970d34e0f69711f5
6
+ metadata.gz: 6ee1f61de34d63d0b4369f0d8ddd3cc9a020b63b071b946e84b86642755fe31ad05d89316aead3a9bbba18fcddf087e69d425ed6a5fc23a20c89e1ad473eb3a2
7
+ data.tar.gz: 90ef1c0427b3fc1d7d79c72106f949f212c45943791de20142963a61b523307998b2668cb0a6107a358f10e63af0fa8daf138a4c49911c52c486ce520957dbb0
@@ -157,20 +157,21 @@ module BpmManager
157
157
  private_class_method :calculate_sla
158
158
 
159
159
  def self.calculate_sla_percent(start, sla_hours = 0.0, offset = 20)
160
- sla_hours = sla_hours.to_f * 3600 # converts to seconds
160
+ sla_hours = sla_hours * 3600.0 # converts to seconds
161
+ offset_pcg = (100.0 - offset) / 100.0
161
162
  percent = OpenStruct.new
162
163
 
163
- unless sla_hours < 1
164
- if Time.now.utc > (start.utc + sla_hours) # Still Green
165
- total = (start.utc + sla_hours).to_f
166
- percent.green = ((sla_hours * (100 - offset) / 100) / total * 100).round(2)
167
- percent.yellow = (Time.now.utc > start.utc + (sla_hours * (100 - offset) / 100)) ? ((sla_hours / total * 100) - percent.green).round(2) : 0.0
168
- percent.red = 0.0
169
- else # Ruby Red
164
+ unless sla_hours < 1 # it's zero or negative
165
+ if Time.now.utc > (start.utc + sla_hours) # Ruby Red
170
166
  total = (Time.now.utc - start.utc).to_f
171
- percent.green = ((sla_hours * (100 - offset) / 100) / total * 100).round(2)
167
+ percent.green = (sla_hours * offset_pcg / total * 100).round(2)
172
168
  percent.yellow = ((sla_hours / total * 100) - percent.green).round(2)
173
169
  percent.red = (100 - percent.yellow - percent.green).round(2)
170
+ else # Still Green
171
+ total = sla_hours
172
+ 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
173
+ 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)
174
+ percent.red = 0.0
174
175
  end
175
176
  else
176
177
  percent.green = 100.0
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "0.9.16"
2
+ VERSION = "0.10.0"
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: 0.9.16
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 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: rest-client