bpm_manager 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bpm_manager/red_hat.rb +42 -0
- data/lib/bpm_manager/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2447f095243eadeb0cdb652f998b53887e402665
|
4
|
+
data.tar.gz: 902c7dd6e4e5bc891ba40cdb48cca5ce309c63a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5796302fb793aa29dc042864ad1c46585251f059e8362f7cd1adc5c0bb4ab9dbd0f0d64d4390207a805ed9c38e5fd1b381961bdba9f628651e9b99d16ca513d0
|
7
|
+
data.tar.gz: 1c05c05830789c068b2a020f65f006a12318fbd9256cb55c1ba35b2b8a727d491965daaa436a2d8da1f6c1251b84a20df61fd1aade49fd6089c59e962569c1ed
|
data/lib/bpm_manager/red_hat.rb
CHANGED
@@ -122,6 +122,29 @@ module BpmManager
|
|
122
122
|
RestClient.post(URI.encode(BpmManager.uri('/history/clear')), :headers => {:content_type => :json, :accept => :json})
|
123
123
|
end
|
124
124
|
|
125
|
+
# Gets the SLA for a Process Instance
|
126
|
+
def self.get_task_sla(task_instance_id, process_sla_hours = 0, task_sla_hours = 0, warning_offset_percent = 20)
|
127
|
+
sla = OpenStruct.new
|
128
|
+
sla.task = OpenStruct.new
|
129
|
+
sla.process = OpenStruct.new
|
130
|
+
my_task = self.tasks_with_opts(:taskId => task_instance_id).first
|
131
|
+
|
132
|
+
unless my_task.nil?
|
133
|
+
else
|
134
|
+
# Calculates the process sla
|
135
|
+
sla.process.status = calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent)
|
136
|
+
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')
|
137
|
+
sla.process.percent = calculate_sla_percent(my_task.process.start_on, process_sla_hours, warning_offset_percent)
|
138
|
+
|
139
|
+
# Calculates the task sla
|
140
|
+
sla.task.status = calculate_sla(my_task.task.created_on, task_sla_hours, warning_offset_percent)
|
141
|
+
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')
|
142
|
+
sla.task.percent = calculate_sla_percent(my_task.created_on, task_sla_hours, warning_offset_percent)
|
143
|
+
end
|
144
|
+
|
145
|
+
return sla
|
146
|
+
end
|
147
|
+
|
125
148
|
private
|
126
149
|
def self.structure_task_data(input)
|
127
150
|
tasks = []
|
@@ -158,5 +181,24 @@ module BpmManager
|
|
158
181
|
|
159
182
|
return tasks
|
160
183
|
end
|
184
|
+
|
185
|
+
def calculate_sla(start, sla_hours=0, offset=20)
|
186
|
+
unless sla_hours > 0
|
187
|
+
(start.to_f + ((sla_hours.to_f * 7*24*60*60))*((100-offset)/100)) <= Time.now.utc.to_f ? 0 : ((start.to_f + (sla_hours.to_f * 7*24*60*60) <= Time.now.utc.to_f) ? 1 : 2)
|
188
|
+
else
|
189
|
+
0
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def calculate_sla_percent(start, sla_hours=0, offset=20)
|
194
|
+
percent = OpenStruct.new
|
195
|
+
total = Time.now.utf.to_f - start.to_f
|
196
|
+
|
197
|
+
percent.green = sla_hours > 0 ? (start.to_f + ((sla_hours.to_f * 7*24*60*60)) * ((100-offset)/100)) / total * 100 : 100
|
198
|
+
percent.yellow = sla_hours > 0 ? (start.to_f + ((sla_hours.to_f * 7*24*60*60)) / total * 100) - green : 0
|
199
|
+
percent.red = sla_hours > 0 ? 100 - yellow - green : 0
|
200
|
+
|
201
|
+
return percent
|
202
|
+
end
|
161
203
|
end
|
162
204
|
end
|
data/lib/bpm_manager/version.rb
CHANGED