bpm_manager 0.9.15 → 0.9.16

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: c7cda6c92e1dc70138e1ae9d38addc485688961b
4
- data.tar.gz: 2600f6b6378c22d4ac017e55e08b863309d4dbfc
3
+ metadata.gz: 4e3b5c1eadedf5de66e46f004736de6881b0fe8d
4
+ data.tar.gz: b0d13b931a1960e2002fe7289a04ede0e2b80f1e
5
5
  SHA512:
6
- metadata.gz: 069e4279b319513f2b82d95c8bb4deb9605280373e56fb481fd75ea9777710ebb49d2849aca2a1faea935e1ad08ae4bee5716b1e5f4ea1b8064f75cc107e86bf
7
- data.tar.gz: 65155fd41f52d4a2b548e5a4447f1c7ff1d19c943dbb5ae380926ba67d93e1853e58a9c8612b37d3ad8264e8f5a81a8db344091cdcc55f19e6cc9de5d874da0c
6
+ metadata.gz: b21c4533a24490bdb5fcd99b00037aa649f35dfc9bea8c450e0b44936690e0e5fee6d3c8542b32e32e46bf1653f2b3e041a6e3a138bc842340fc755a8419b921
7
+ data.tar.gz: 3d6815e7f7655788a1440ed8cdb267833317e266983d6fe352ae5b48e5e114202a8416dd8ba6a498317134e7b8672be7686436d84dad573c970d34e0f69711f5
@@ -157,13 +157,26 @@ 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
- total = Time.now.utc > start.utc ? (Time.now.utc - start.utc).to_f : (start.utc - Time.now.utc).to_f
161
160
  sla_hours = sla_hours.to_f * 3600 # converts to seconds
162
-
163
161
  percent = OpenStruct.new
164
- percent.green = sla_hours > 0 ? ((sla_hours * (100 - offset) / 100) / total * 100).round(2) : 100
165
- percent.yellow = sla_hours > 0 ? ((sla_hours / total * 100) - percent.green).round(2) : 0
166
- percent.red = sla_hours > 0 ? (100 - percent.yellow - percent.green).round(2) : 0
162
+
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
170
+ total = (Time.now.utc - start.utc).to_f
171
+ percent.green = ((sla_hours * (100 - offset) / 100) / total * 100).round(2)
172
+ percent.yellow = ((sla_hours / total * 100) - percent.green).round(2)
173
+ percent.red = (100 - percent.yellow - percent.green).round(2)
174
+ end
175
+ else
176
+ percent.green = 100.0
177
+ percent.yellow = 0.0
178
+ percent.red = 0.0
179
+ end
167
180
 
168
181
  return percent
169
182
  end
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "0.9.15"
2
+ VERSION = "0.9.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpm_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.15
4
+ version: 0.9.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa