@@ -213,10 +213,14 @@ $(document).ready(function () {
213
213
jsonRPC ( 'Testing.individual_test_case_health' , { case_id : case_id } , ress => {
214
214
const res = { }
215
215
let planId = 0
216
+ let positive = 0
217
+ let negative = 0
218
+ let allCount = 0
216
219
ress . forEach ( r => {
217
- let positive = 0
218
- let negative = 0
219
- let allCount = 0
220
+ if ( planId === 0 ) {
221
+ planId = r . run__plan
222
+ }
223
+
220
224
if ( r . status__weight > 0 ) {
221
225
positive ++
222
226
} else if ( r . status__weight < 0 ) {
@@ -226,25 +230,34 @@ $(document).ready(function () {
226
230
227
231
if ( r . run__plan !== planId ) {
228
232
planId = r . run__plan
233
+ const completionRate = allCount > 0 ? ( ( positive + negative ) / allCount ) : 0
234
+ const failureRate = allCount > 0 ? ( negative / allCount ) : 0
229
235
res [ planId ] = {
230
- completion_rate : allCount > 0 ? ( ( positive + negative ) / allCount ) : 0 ,
231
- failure_rate : allCount > 0 ? ( negative / allCount ) : 0
236
+ completionRate : completionRate . toFixed ( 2 ) ,
237
+ failureRate : failureRate . toFixed ( 2 )
232
238
}
233
239
positive = 0
234
240
negative = 0
235
241
allCount = 0
236
242
}
237
243
} )
244
+ // add the last entry
245
+ const completionRate = allCount > 0 ? ( ( positive + negative ) / allCount ) : 0
246
+ const failureRate = allCount > 0 ? ( negative / allCount ) : 0
247
+ res [ planId ] = {
248
+ completionRate : completionRate . toFixed ( 2 ) ,
249
+ failureRate : failureRate . toFixed ( 2 )
250
+ }
238
251
239
252
Object . entries ( res ) . forEach ( ( [ runId , data ] ) => {
240
253
const executionRow = $ ( `#execution-for-plan-${ runId } ` )
241
- executionRow . find ( '.completion-rate' ) . html ( data . completion_rate )
242
- executionRow . find ( '.completion-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( 1 - data . completion_rate ) * 100 } %` )
243
- executionRow . find ( '.completion-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( data . completion_rate ) * 100 } %` )
254
+ executionRow . find ( '.completion-rate' ) . html ( data . completionRate )
255
+ executionRow . find ( '.completion-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( 1 - data . completionRate ) * 100 } %` )
256
+ executionRow . find ( '.completion-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( data . completionRate ) * 100 } %` )
244
257
245
- executionRow . find ( '.failure-rate' ) . html ( data . failure_rate )
246
- executionRow . find ( '.failure-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( data . failure_rate ) * 100 } %` )
247
- executionRow . find ( '.failure-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( 1 - data . failure_rate ) * 100 } %` )
258
+ executionRow . find ( '.failure-rate' ) . html ( data . failureRate )
259
+ executionRow . find ( '.failure-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( data . failureRate ) * 100 } %` )
260
+ executionRow . find ( '.failure-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( 1 - data . failureRate ) * 100 } %` )
248
261
} )
249
262
} )
250
263
@@ -259,4 +272,4 @@ $(document).ready(function () {
259
272
260
273
// executions treeview
261
274
treeViewBind ( )
262
- } )
275
+ } )
0 commit comments