From f83bb9392523452a325fbe59d9ba8602922b0761 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 19 Jan 2024 16:49:30 +0000 Subject: [PATCH] feat: Parse the DefinitionList at source Ensure there are always "some" values for TimeLocalExecute Signed-off-by: Gordon Smith --- packages/comms/src/ecl/workunit.ts | 32 +++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/comms/src/ecl/workunit.ts b/packages/comms/src/ecl/workunit.ts index eb3716ca9b..50d47e48ed 100644 --- a/packages/comms/src/ecl/workunit.ts +++ b/packages/comms/src/ecl/workunit.ts @@ -22,6 +22,8 @@ function formatNum(num: number | string): string { } return num as string; } +const DEFINITION_LIST = "DefinitionList"; +const definitionRegex = /([a-zA-Z]:)?(.*[\\/])(.*)(\((\d+),(\d+)\))/; const logger = scopedLogger("workunit.ts"); @@ -381,7 +383,7 @@ export class Workunit extends StateObject implem abort() { return this.WUAction("Abort"); } - + protect() { return this.WUAction("Protect"); } @@ -589,16 +591,36 @@ export class Workunit extends StateObject implem props[scopeProperty.Name] = scopeProperty.RawValue; } formattedProps[scopeProperty.Name] = formatNum(scopeProperty.Formatted ?? props[scopeProperty.Name]); - } + // Other properties --- } - data.push({ + const normalizedScope = { id: scope.Id, name: scope.ScopeName, type: scope.ScopeType, __formattedProps: formattedProps, - ...props - }); + ...props, + TimeElapsed: props["TimeElapsed"] ?? props["TimeMaxElapsed"] ?? props["TimeAvgElapsed"], + TimeLocalExecute: props["TimeLocalExecute"] ?? props["TimeMaxLocalExecute"] ?? props["TimeAvgLocalExecute"] + }; + if (normalizedScope[DEFINITION_LIST]) { + normalizedScope.__formattedProps[DEFINITION_LIST] = []; + try { + const definitionList = JSON.parse(normalizedScope[DEFINITION_LIST].split("\\").join("\\\\")); + definitionList.forEach((definition, idx) => { + const matches = definition.match(definitionRegex); + if (matches) { + const filePath = (matches[1] ?? "") + matches[2] + matches[3]; + const line = parseInt(matches[5]); + const col = parseInt(matches[6]); + normalizedScope.__formattedProps[DEFINITION_LIST].push({ filePath, line, col }); + } + }); + } catch (e) { + logger.error(`Unexpected "DefinitionList": ${normalizedScope[DEFINITION_LIST]}`); + } + } + data.push(normalizedScope); } return { meta,