@@ -263,14 +263,18 @@ export interface useMetricsResult {
263
263
refresh : ( ) => void ;
264
264
}
265
265
266
+ export interface IScopeEx extends IScope {
267
+ __exceptions ?: WsWorkunits . ECLException [ ] ,
268
+ }
269
+
266
270
export function useWorkunitMetrics (
267
271
wuid : string ,
268
272
scopeFilter : Partial < WsWorkunits . ScopeFilter > = scopeFilterDefault ,
269
273
nestedFilter : WsWorkunits . NestedFilter = nestedFilterDefault
270
274
) : useMetricsResult {
271
275
272
276
const [ workunit , state ] = useWorkunit ( wuid ) ;
273
- const [ data , setData ] = React . useState < IScope [ ] > ( [ ] ) ;
277
+ const [ data , setData ] = React . useState < IScopeEx [ ] > ( [ ] ) ;
274
278
const [ columns , setColumns ] = React . useState < { [ id : string ] : any } > ( [ ] ) ;
275
279
const [ activities , setActivities ] = React . useState < WsWorkunits . Activity2 [ ] > ( [ ] ) ;
276
280
const [ properties , setProperties ] = React . useState < WsWorkunits . Property2 [ ] > ( [ ] ) ;
@@ -281,40 +285,58 @@ export function useWorkunitMetrics(
281
285
282
286
React . useEffect ( ( ) => {
283
287
if ( wuid && workunit ) {
288
+ const fetchInfo = singletonDebounce ( workunit , "fetchInfo" ) ;
284
289
const fetchDetailsNormalized = singletonDebounce ( workunit , "fetchDetailsNormalized" ) ;
285
290
setStatus ( FetchStatus . STARTED ) ;
286
- fetchDetailsNormalized ( {
287
- ScopeFilter : scopeFilter ,
288
- NestedFilter : nestedFilter ,
289
- PropertiesToReturn : {
290
- AllScopes : true ,
291
- AllAttributes : true ,
292
- AllProperties : true ,
293
- AllNotes : true ,
294
- AllStatistics : true ,
295
- AllHints : true
296
- } ,
297
- ScopeOptions : {
298
- IncludeId : true ,
299
- IncludeScope : true ,
300
- IncludeScopeType : true ,
301
- IncludeMatchedScopesInResults : true
302
- } ,
303
- PropertyOptions : {
304
- IncludeName : true ,
305
- IncludeRawValue : true ,
306
- IncludeFormatted : true ,
307
- IncludeMeasure : true ,
308
- IncludeCreator : false ,
309
- IncludeCreatorType : false
291
+ Promise . all ( [
292
+ fetchInfo ( { IncludeExceptions : true } ) ,
293
+ fetchDetailsNormalized ( {
294
+ ScopeFilter : scopeFilter ,
295
+ NestedFilter : nestedFilter ,
296
+ PropertiesToReturn : {
297
+ AllScopes : true ,
298
+ AllAttributes : true ,
299
+ AllProperties : true ,
300
+ AllNotes : true ,
301
+ AllStatistics : true ,
302
+ AllHints : true
303
+ } ,
304
+ ScopeOptions : {
305
+ IncludeId : true ,
306
+ IncludeScope : true ,
307
+ IncludeScopeType : true ,
308
+ IncludeMatchedScopesInResults : true
309
+ } ,
310
+ PropertyOptions : {
311
+ IncludeName : true ,
312
+ IncludeRawValue : true ,
313
+ IncludeFormatted : true ,
314
+ IncludeMeasure : true ,
315
+ IncludeCreator : false ,
316
+ IncludeCreatorType : false
317
+ }
318
+ } )
319
+ ] ) . then ( ( [ info , response ] ) => {
320
+ const exceptionsMap : { [ scope : string ] : WsWorkunits . ECLException [ ] } = { } ;
321
+ for ( const exception of info ?. Workunit ?. Exceptions ?. ECLException ?? [ ] ) {
322
+ if ( exception . Scope ) {
323
+ if ( ! exceptionsMap [ exception . Scope ] ) {
324
+ exceptionsMap [ exception . Scope ] = [ ] ;
325
+ }
326
+ exceptionsMap [ exception . Scope ] . push ( exception ) ;
327
+ }
310
328
}
311
- } ) . then ( response => {
312
- setData ( response ?. data ) ;
329
+ setData ( response ?. data . map ( row => {
330
+ if ( exceptionsMap [ row . name ] ) {
331
+ row . __exceptions = exceptionsMap [ row . name ] ;
332
+ }
333
+ return row ;
334
+ } ) ) ;
313
335
setColumns ( response ?. columns ) ;
314
- setActivities ( response ?. meta ?. Activities ?. Activity || [ ] ) ;
315
- setProperties ( response ?. meta ?. Properties ?. Property || [ ] ) ;
316
- setMeasures ( response ?. meta ?. Measures ?. Measure || [ ] ) ;
317
- setScopeTypes ( response ?. meta ?. ScopeTypes ?. ScopeType || [ ] ) ;
336
+ setActivities ( response ?. meta ?. Activities ?. Activity ?? [ ] ) ;
337
+ setProperties ( response ?. meta ?. Properties ?. Property ?? [ ] ) ;
338
+ setMeasures ( response ?. meta ?. Measures ?. Measure ?? [ ] ) ;
339
+ setScopeTypes ( response ?. meta ?. ScopeTypes ?. ScopeType ?? [ ] ) ;
318
340
} ) . catch ( e => {
319
341
logger . error ( e ) ;
320
342
} ) . finally ( ( ) => {
0 commit comments