From 6555a1d5a633609d10720fbe06ce4bc92f4b6e71 Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 2 Jun 2023 16:36:55 +0800 Subject: [PATCH] feat: update percentile --- src/hooks/useExpressionsProcessor.ts | 17 ++++++++++++++--- src/hooks/useMetricsProcessor.ts | 1 - .../configuration/widget/metric/Standard.vue | 12 ++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index 75cd459e..69537d65 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -121,12 +121,23 @@ export function useExpressionsSourceProcessor( const name = ((results[0] || {}).metric || {}).name; if (type === ExpressionResultType.TIME_SERIES_VALUES) { - source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; - return; + if (results.length === 1) { + source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; + } else { + const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, "")); + for (const item of results) { + const values = item.values.map((d: { value: unknown }) => Number(d.value)) || []; + const index = Number(item.metric.labels[0].value); + if (labels[index]) { + source[labels[index]] = values; + } else { + source[index] = values; + } + } + } } if (type === ExpressionResultType.SINGLE_VALUE) { source[c.label || name] = results[0].values[0].value; - return; } if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) { source[name] = results[0].values; diff --git a/src/hooks/useMetricsProcessor.ts b/src/hooks/useMetricsProcessor.ts index 6b72a4b3..e4ad5378 100644 --- a/src/hooks/useMetricsProcessor.ts +++ b/src/hooks/useMetricsProcessor.ts @@ -178,7 +178,6 @@ export function useSourceProcessor( return d; }); - console.log(source); } if (type === MetricQueryTypes.READHEATMAP) { const resVal = Object.values(resp.data)[0] || {}; diff --git a/src/views/dashboard/configuration/widget/metric/Standard.vue b/src/views/dashboard/configuration/widget/metric/Standard.vue index e775d3e2..1442b4f5 100644 --- a/src/views/dashboard/configuration/widget/metric/Standard.vue +++ b/src/views/dashboard/configuration/widget/metric/Standard.vue @@ -56,7 +56,7 @@ limitations under the License. --> " /> -
+
{{ t("aggregation") }} ); }); const isTopn = computed(() => - [ - ProtocolTypes.SortMetrics, - ProtocolTypes.ReadSampledRecords, - ProtocolTypes.ReadRecords, - ExpressionResultType.SORTED_LIST, - ExpressionResultType.RECORD_LIST, - ].includes(metricTypes.value[props.index]), + [ProtocolTypes.SortMetrics, ProtocolTypes.ReadSampledRecords, ProtocolTypes.ReadRecords].includes( + metricTypes.value[props.index], + ), ); function updateConfig(index: number, param: { [key: string]: string }) { const key = Object.keys(param)[0];