From 0db3c0677033b10f49d8fc51c32d0573360773e3 Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 2 Jun 2023 15:59:08 +0800 Subject: [PATCH] refactor: update --- src/hooks/useExpressionsProcessor.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index abbc051b..75cd459e 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -114,10 +114,10 @@ export function useExpressionsSourceProcessor( } const source: { [key: string]: unknown } = {}; const keys = Object.keys(resp.data); - - config.metricTypes.forEach((type: string, index) => { - const c = (config.metricConfig && config.metricConfig[index]) || {}; - const results = (resp.data[keys[index]] && resp.data[keys[index]].results) || []; + for (let i = 0; i < config.metricTypes.length; i++) { + const type = config.metricTypes[i]; + const c = (config.metricConfig && config.metricConfig[i]) || {}; + const results = (resp.data[keys[i]] && resp.data[keys[i]].results) || []; const name = ((results[0] || {}).metric || {}).name; if (type === ExpressionResultType.TIME_SERIES_VALUES) { @@ -131,7 +131,7 @@ export function useExpressionsSourceProcessor( if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) { source[name] = results[0].values; } - }); + } return source; }