bpm_manager 0.9.12 → 0.9.13

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: 7c7da5c736b1f636f350b7140e10af65bdf9b60f
4
- data.tar.gz: 6ec59d7dad432a45a9f2133224f822afb49a6976
3
+ metadata.gz: 3d32365d205fa3caf9f8dde5176f45894ada9641
4
+ data.tar.gz: 7a9c10fc5c8a62c371efcd6a648d06a823d14532
5
5
  SHA512:
6
- metadata.gz: ee7ade62ce2ed0377ad696564a8e8a13cd6d2e01e10206fec449af1166482f84137e639d1e3420aa9ef228d193957efd94964467d5c22e5e464b0a56f66e70fe
7
- data.tar.gz: 631948cc229a6ebe8df077b8a19807bfa84470039b5c713d0bb6ef01653b4b9ead6336fc4c7ff403e6115a04e6be3a9fbdf0991975893e0f54e7fe88a500fd29
6
+ metadata.gz: e08d29baf879a6013dfb077769c8df452d3193b432476b55b7e7af32d39e33eed81c999c6388f23d41f5f3a4e2a634c52169d6ee9ede1c0f9472e81dffb2e4dd
7
+ data.tar.gz: 19773372ddb9796d42219bebdfa9ed6b5e2278df931c33036bf70ff7e527b32b19108a5902440fcc85563dd9368b1e065d287471a6628e15e77109a5ba91cf06
@@ -148,30 +148,24 @@ module BpmManager
148
148
  # Private class methods
149
149
  def self.calculate_sla(start, sla_hours = 0.0, offset = 20)
150
150
  # Converts to seconds and calculates warning offset
151
- sla_hours = sla_hours.to_f * 3600 * ((100 - offset) / 100)
151
+ sla_hours_ok = sla_hours.to_f * 3600
152
+ sla_hours_warn = sla_hours_ok * ((100 - offset) / 100)
152
153
 
153
- if sla_hours > 0
154
- if start.utc + sla_hours >= Time.now.utc
155
- 0
156
- else
157
- start.utc + sla_hours >= Time.now.utc ? 1 : 2
158
- end
159
- else
160
- 0
161
- end
154
+ # Returns the status
155
+ sla_hours > 0 ? (start.utc + sla_hours_warn >= Time.now.utc ? (start.utc + sla_hours_ok >= Time.now.utc ? 0 : 1) : 2) : 0
162
156
  end
163
157
  private_class_method :calculate_sla
164
158
 
165
- def self.calculate_sla_percent(start, sla_hours=0, offset=20)
166
- sla_hours = sla_hours.to_f * 3600 # converts to seconds
167
- percent = OpenStruct.new
159
+ def self.calculate_sla_percent(start, sla_hours = 0.0, offset = 20)
168
160
  total = (Time.now.utc - start.utc).to_f
161
+ sla_hours = sla_hours.to_f * 3600 # converts to seconds
162
+ percentage = OpenStruct.new
169
163
 
170
- percent.green = sla_hours > 0 ? ((start.utc + (sla_hours * (100 - offset) / 100)).to_f) * 100 / total : 100
171
- percent.yellow = sla_hours > 0 ? ((start.utc + sla_hours).to_f * 100 / total) - percent.green : 0
172
- percent.red = sla_hours > 0 ? 100 - percent.yellow - percent.green : 0
164
+ percentage.green = sla_hours > 0 ? (start.utc + (sla_hours * (100 - offset) / 100)).to_f * 100 / total : 100
165
+ percentage.yellow = sla_hours > 0 ? ((start.utc + sla_hours).to_f * 100 / total) - percent.green : 0
166
+ percentage.red = sla_hours > 0 ? 100 - percent.yellow - percent.green : 0
173
167
 
174
- return percent
168
+ return percentage
175
169
  end
176
170
  private_class_method :calculate_sla_percent
177
171
 
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "0.9.12"
2
+ VERSION = "0.9.13"
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.12
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa